Search in sources :

Example 6 with VoldemortApplicationException

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);
    }
}
Also used : VoldemortApplicationException(voldemort.VoldemortApplicationException)

Example 7 with VoldemortApplicationException

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);
    }
}
Also used : VoldemortApplicationException(voldemort.VoldemortApplicationException) Node(voldemort.cluster.Node) URI(java.net.URI) OptionException(joptsimple.OptionException) VoldemortApplicationException(voldemort.VoldemortApplicationException) UnreachableStoreException(voldemort.store.UnreachableStoreException)

Example 8 with VoldemortApplicationException

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;
}
Also used : VoldemortApplicationException(voldemort.VoldemortApplicationException) StringReader(java.io.StringReader) Cluster(voldemort.cluster.Cluster) ClusterMapper(voldemort.xml.ClusterMapper) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with VoldemortApplicationException

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");
    }
}
Also used : VoldemortApplicationException(voldemort.VoldemortApplicationException) OptionException(joptsimple.OptionException) Cluster(voldemort.cluster.Cluster) OptionSet(joptsimple.OptionSet) Properties(java.util.Properties) OptionParser(joptsimple.OptionParser) File(java.io.File) VoldemortConfig(voldemort.server.VoldemortConfig)

Example 10 with VoldemortApplicationException

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());
        }
    }
}
Also used : VoldemortApplicationException(voldemort.VoldemortApplicationException) Node(voldemort.cluster.Node)

Aggregations

VoldemortApplicationException (voldemort.VoldemortApplicationException)19 Node (voldemort.cluster.Node)10 UnreachableStoreException (voldemort.store.UnreachableStoreException)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 ExecutionException (java.util.concurrent.ExecutionException)4 OptionException (joptsimple.OptionException)4 VoldemortException (voldemort.VoldemortException)4 InsufficientOperationalNodesException (voldemort.store.InsufficientOperationalNodesException)4 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Cluster (voldemort.cluster.Cluster)3 StoreDefinition (voldemort.store.StoreDefinition)3 StringReader (java.io.StringReader)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Callable (java.util.concurrent.Callable)2 Future (java.util.concurrent.Future)2 Semaphore (java.util.concurrent.Semaphore)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2