Madan Jampani

Trivial logging change

Change-Id: I8166b5cb886c16b30ad28886a000525ab2059943

Enabling Raft based device mastership store

Change-Id: Ide4dc559aa241ec2f3fa587701f6f32ba6856218
......@@ -40,8 +40,8 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
description = "Finds the leader for particular topic.")
public class LeaderCommand extends AbstractShellCommand {
private static final String FMT = "%-20s | %-15s | %-6s | %-10s |";
private static final String FMT_C = "%-20s | %-15s | %-19s |";
private static final String FMT = "%-30s | %-15s | %-6s | %-10s |";
private static final String FMT_C = "%-30s | %-15s | %-19s |";
private boolean allTopics;
private Pattern pattern;
......@@ -77,9 +77,9 @@ public class LeaderCommand extends AbstractShellCommand {
* @param leaderBoard map of leaders
*/
private void displayLeaders(Map<String, Leadership> leaderBoard) {
print("--------------------------------------------------------------");
print("------------------------------------------------------------------------");
print(FMT, "Topic", "Leader", "Epoch", "Elected");
print("--------------------------------------------------------------");
print("------------------------------------------------------------------------");
leaderBoard.values()
.stream()
......@@ -90,14 +90,14 @@ public class LeaderCommand extends AbstractShellCommand {
l.leader(),
l.epoch(),
Tools.timeAgo(l.electedTime())));
print("--------------------------------------------------------------");
print("------------------------------------------------------------------------");
}
private void displayCandidates(Map<String, Leadership> leaderBoard,
Map<String, List<NodeId>> candidates) {
print("--------------------------------------------------------------");
print("------------------------------------------------------------------------");
print(FMT_C, "Topic", "Leader", "Candidates");
print("--------------------------------------------------------------");
print("------------------------------------------------------------------------");
candidates
.entrySet()
.stream()
......@@ -116,7 +116,7 @@ public class LeaderCommand extends AbstractShellCommand {
list.subList(1, list.size()).forEach(n -> print(FMT_C, " ", " ", n));
print(FMT_C, " ", " ", " ");
});
print("--------------------------------------------------------------");
print("------------------------------------------------------------------------");
}
/**
......
......@@ -36,12 +36,12 @@ public class LogicalClockManager implements LogicalClockService {
.withName(SYSTEM_LOGICAL_CLOCK_COUNTER_NAME)
.withPartitionsDisabled()
.build();
log.info("Started.");
log.info("Started");
}
@Deactivate
public void deactivate() {
log.info("Stopped.");
log.info("Stopped");
}
@Override
......
......@@ -69,7 +69,7 @@ import com.google.common.collect.Sets;
/**
* Implementation of the MastershipStore on top of Leadership Service.
*/
@Component(immediate = true, enabled = false)
@Component(immediate = true, enabled = true)
@Service
public class ConsistentDeviceMastershipStore
extends AbstractStore<MastershipEvent, MastershipStoreDelegate>
......@@ -95,9 +95,8 @@ public class ConsistentDeviceMastershipStore
new MessageSubject("mastership-store-device-role-relinquish");
private static final Pattern DEVICE_MASTERSHIP_TOPIC_PATTERN =
Pattern.compile("/devices/(.*)/mastership");
Pattern.compile("device:(.*)");
private static final long PEER_REQUEST_TIMEOUT_MS = 5000;
private ExecutorService messageHandlingExecutor;
private final LeadershipEventListener leadershipEventListener =
new InternalDeviceMastershipEventListener();
......@@ -345,7 +344,7 @@ public class ConsistentDeviceMastershipStore
}
private String createDeviceMastershipTopic(DeviceId deviceId) {
return "/devices/" + deviceId.toString() + "/mastership";
return String.format("device:%s", deviceId.toString());
}
private DeviceId extractDeviceIdFromTopic(String topic) {
......
......@@ -60,7 +60,7 @@ import static org.onosproject.net.MastershipRole.*;
* Distributed implementation of the mastership store. The store is
* responsible for the master selection process.
*/
@Component(immediate = true)
@Component(immediate = true, enabled = false)
@Service
public class DistributedMastershipStore
extends AbstractHazelcastStore<MastershipEvent, MastershipStoreDelegate>
......