use of voldemort.VoldemortApplicationException in project voldemort by voldemort.
the class ReplaceNodeCLI method verifyPostConditions.
private void verifyPostConditions() {
try {
getClusterXML();
getStoresXML();
} catch (VoldemortApplicationException e) {
throw new VoldemortApplicationException(" Verify Post conditions failed after the node is replaced " + e.getMessage(), e);
}
}
use of voldemort.VoldemortApplicationException in project voldemort by voldemort.
the class ReplaceNodeCLI method verifyAdminPort.
private void verifyAdminPort(Collection<Node> nodes, String url) {
boolean isAdminPortUsed = false;
for (Node node : nodes) {
int adminPort = node.getAdminPort();
URI bootstrapUrl = null;
try {
bootstrapUrl = new URI(url);
} catch (Exception e) {
logger.error("error parsing url " + url, e);
throw new VoldemortApplicationException("error parsing url " + url + " " + e.getMessage());
}
int urlPort = bootstrapUrl.getPort();
if (urlPort == adminPort) {
isAdminPortUsed = true;
break;
}
}
if (isAdminPortUsed == false) {
throw new VoldemortApplicationException("The bootstrap URL should point to the admin port as the client port will be made offline ... aborting " + " url " + url);
}
}
use of voldemort.VoldemortApplicationException in project voldemort by voldemort.
the class ReplaceNodeCLI method getClusterXML.
private String getClusterXML() {
ClusterMapper clusterMapper = new ClusterMapper();
Cluster existingCluster = null;
String clusterXML = null;
Map<Integer, String> clusterXMLInNodes = getMetadataXML(MetadataStore.CLUSTER_KEY);
for (Map.Entry<Integer, String> clusterNodeId : clusterXMLInNodes.entrySet()) {
String xml = clusterNodeId.getValue();
Cluster cluster = clusterMapper.readCluster(new StringReader(xml), false);
if (existingCluster == null) {
existingCluster = cluster;
clusterXML = xml;
} else if (existingCluster.equals(cluster) == false) {
throw new VoldemortApplicationException("Cluster XMLs are different across nodes, fix that before the node swap...aborting " + clusterNodeId.getKey());
}
}
return clusterXML;
}
use of voldemort.VoldemortApplicationException in project voldemort by voldemort.
the class ValidateNodeIdCLI method main.
public static void main(String[] args) throws IOException {
OptionParser parser = null;
OptionSet options = null;
try {
parser = setupParser();
options = parser.parse(args);
} catch (OptionException oe) {
parser.printHelpOn(System.out);
printUsageAndDie("Exception when parsing arguments : " + oe.getMessage());
return;
}
/* validate options */
if (options.has("help")) {
printUsage();
return;
}
if (!options.hasArgument("id") || !options.hasArgument("path")) {
printUsageAndDie("Missing a required argument.");
return;
}
String id = (String) options.valueOf("id");
int expectedNodeId = Integer.parseInt(id);
String clusterPaths = getFilePath(options, "path");
String[] allPaths = clusterPaths.split(",");
boolean isMatch = false;
for (String path : allPaths) {
path = path.replace("~", System.getProperty("user.home"));
File filePath = new File(path);
if (filePath.exists()) {
isMatch = true;
Cluster cluster = getCluster(filePath);
Properties properties = new Properties();
properties.setProperty(VoldemortConfig.ENABLE_NODE_ID_DETECTION, Boolean.toString(true));
properties.setProperty(VoldemortConfig.VOLDEMORT_HOME, getTempDirPath());
VoldemortConfig config = new VoldemortConfig(properties);
int actualNodeId = VoldemortServer.getNodeId(config, cluster);
if (actualNodeId != expectedNodeId) {
throw new VoldemortApplicationException("Mismatch detected. Computed Node Id " + actualNodeId + " Expected " + expectedNodeId);
} else {
System.out.println("Expected and Computed node Id matched " + expectedNodeId);
}
config.setNodeId(actualNodeId);
VoldemortServer.validateNodeId(config, cluster);
System.out.println("Validation of node Id passed");
}
}
if (!isMatch) {
throw new VoldemortApplicationException("None of the paths matched the cluster.xml");
}
}
use of voldemort.VoldemortApplicationException in project voldemort by voldemort.
the class VoldemortServer method refreshNodeIdFromMetadata.
public void refreshNodeIdFromMetadata() {
int nodeId = this.metadata.getNodeId();
voldemortConfig.setNodeId(nodeId);
validateNodeId();
Node oldNode = this.identityNode;
this.identityNode = metadata.getCluster().getNodeById(nodeId);
if (oldNode != null) {
if (oldNode.getSocketPort() != this.identityNode.getSocketPort() || oldNode.getAdminPort() != this.identityNode.getAdminPort()) {
throw new VoldemortApplicationException("Node Id update, changes the Socket And Or Admin Port. " + "The Server will be in an inconsistent state, until the next restart. Old State " + oldNode.getStateString() + "New State " + this.identityNode.getStateString());
}
}
}
Aggregations