blob: 5e9301dc9077dbf7fbf93e1dc2dd6fa2d6d28802 [file] [log] [blame]
Jordan Halterman07f052b2017-10-08 14:22:41 -07001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.store.primitives.impl;
17
18import java.io.File;
19import java.util.concurrent.CompletableFuture;
20
21import io.atomix.protocols.raft.cluster.MemberId;
22import org.onosproject.cluster.ClusterService;
23import org.onosproject.cluster.Partition;
24import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
25
26/**
27 * Storage partition active on the local node.
28 */
29public class ActiveStoragePartition extends StoragePartition {
30 public ActiveStoragePartition(
31 Partition partition,
32 ClusterCommunicationService clusterCommunicator,
33 ClusterService clusterService) {
34 super(partition, clusterCommunicator, clusterService);
35 }
36
37 @Override
38 public String getName() {
39 return partition.getId().toString();
40 }
41
42 @Override
43 public File getDataFolder() {
44 return new File(PARTITIONS_DIR + partition.getId());
45 }
46
47 @Override
48 protected CompletableFuture<Void> openServer() {
49 StoragePartitionServer server = new StoragePartitionServer(
50 this,
51 MemberId.from(localNodeId.id()),
52 clusterCommunicator);
53 return server.open().thenRun(() -> this.server = server);
54 }
55}