Search in sources :

Example 81 with VoldemortException

use of voldemort.VoldemortException in project voldemort by voldemort.

the class VerifyOrAddStoreTest method verifyMisMatchFails.

@Test
public void verifyMisMatchFails() throws Exception {
    StoreDefinition incompatibleDef = getIncompatibleStoreDef();
    // Add the incompatible store definition to Node 0
    adminClient.storeMgmtOps.addStore(incompatibleDef, FAILED_NODE_ID);
    // Adding the store with different definition should fail.
    try {
        adminClient.storeMgmtOps.verifyOrAddStore(newStoreDef, PROCESS_NAME, false, service);
        Assert.fail("Non existent store create with flag disabled should have thrown error");
    } catch (VoldemortException ex) {
    // Pass
    }
    for (Integer nodeId : cluster.getNodeIds()) {
        StoreDefinition retrieved = retrieveStoreOnNode(newStoreName, nodeId);
        if (nodeId == FAILED_NODE_ID) {
            assertEquals("mismatched store def should be left intact", incompatibleDef, retrieved);
        } else {
            assertNull("Store should not exist in this node", retrieved);
        }
    }
}
Also used : StoreDefinition(voldemort.store.StoreDefinition) VoldemortException(voldemort.VoldemortException) Test(org.junit.Test)

Example 82 with VoldemortException

use of voldemort.VoldemortException in project voldemort by voldemort.

the class OfflineStateTest method testSlopStreaming.

private boolean testSlopStreaming() {
    final List<Versioned<Slop>> entrySet = ServerTestUtils.createRandomSlops(0, 10000, testStoreName, "users", "test-replication-persistent", "test-readrepair-memory", "test-consistent", "test-consistent-with-pref-list");
    Iterator<Versioned<Slop>> slopIterator = entrySet.iterator();
    try {
        getAdminClient().streamingOps.updateSlopEntries(0, slopIterator);
    } catch (VoldemortException e) {
        return false;
    }
    // check updated values
    Iterator<Versioned<Slop>> entrysetItr = entrySet.iterator();
    while (entrysetItr.hasNext()) {
        Versioned<Slop> versioned = entrysetItr.next();
        Slop nextSlop = versioned.getValue();
        Store<ByteArray, byte[], byte[]> store = getStore(0, nextSlop.getStoreName());
        if (nextSlop.getOperation().equals(Slop.Operation.PUT)) {
            return store.get(nextSlop.getKey(), null).size() != 0;
        } else if (nextSlop.getOperation().equals(Slop.Operation.DELETE)) {
            return store.get(nextSlop.getKey(), null).size() == 0;
        }
    }
    return false;
}
Also used : Versioned(voldemort.versioning.Versioned) ByteArray(voldemort.utils.ByteArray) VoldemortException(voldemort.VoldemortException) Slop(voldemort.store.slop.Slop)

Example 83 with VoldemortException

use of voldemort.VoldemortException in project voldemort by voldemort.

the class ClientRegistryTest method getClientRegistryContent.

private ArrayList<ClientInfo> getClientRegistryContent(Iterator<Pair<ByteArray, Versioned<byte[]>>> it) {
    ArrayList<ClientInfo> infoList = Lists.newArrayList();
    while (it.hasNext()) {
        String clientInfoString = (String) valueSerializer.toObject(it.next().getSecond().getValue());
        Properties props = new Properties();
        try {
            props.load(new ByteArrayInputStream(clientInfoString.getBytes()));
        } catch (IOException ex) {
            throw new VoldemortException("Error loading clientInfo " + props.toString(), ex);
        }
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.setMaxConnectionsPerNode(Integer.parseInt(props.getProperty("max_connections"))).setRoutingTimeout(Integer.parseInt(props.getProperty("routing_timeout_ms")), TimeUnit.MILLISECONDS).setConnectionTimeout(Integer.parseInt(props.getProperty("connection_timeout_ms")), TimeUnit.MILLISECONDS).setSocketTimeout(Integer.parseInt(props.getProperty("socket_timeout_ms")), TimeUnit.MILLISECONDS).setClientZoneId(Integer.parseInt(props.getProperty("client_zone_id"))).setFailureDetectorImplementation(props.getProperty("failuredetector_implementation"));
        ClientInfo cInfo = new ClientInfo(props.getProperty("storeName"), props.getProperty("context"), Integer.parseInt(props.getProperty("sequence")), Long.parseLong(props.getProperty("bootstrapTime")), props.getProperty("releaseVersion"), clientConfig);
        cInfo.setUpdateTime(Long.parseLong(props.getProperty("updateTime")));
        cInfo.setDeploymentPath(props.getProperty("deploymentPath"));
        cInfo.setLocalHostName(props.getProperty("localHostName"));
        infoList.add(cInfo);
    }
    return infoList;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) Properties(java.util.Properties) VoldemortException(voldemort.VoldemortException)

Example 84 with VoldemortException

use of voldemort.VoldemortException in project voldemort by voldemort.

the class VoldemortServer method validateReadOnlyStoreStatusBeforeGoingOnline.

private ReadOnlyStoreStatusValidation validateReadOnlyStoreStatusBeforeGoingOnline() {
    List<StorageEngine<ByteArray, byte[], byte[]>> storageEngines = storageService.getStoreRepository().getStorageEnginesByClass(ReadOnlyStorageEngine.class);
    if (storageEngines.isEmpty()) {
        logger.debug("There are no Read-Only stores on this node.");
        return new ReadOnlyStoreStatusValidation(true, null);
    } else {
        List<String> storesWithDisabledVersions = Lists.newArrayList();
        for (StorageEngine storageEngine : storageEngines) {
            StoreVersionManager storeVersionManager = (StoreVersionManager) storageEngine.getCapability(StoreCapabilityType.DISABLE_STORE_VERSION);
            if (storeVersionManager.hasAnyDisabledVersion()) {
                storesWithDisabledVersions.add(storageEngine.getName());
            }
        }
        if (storesWithDisabledVersions.isEmpty()) {
            if (voldemortConfig.getHighAvailabilityStateAutoCleanUp()) {
                logger.info(VoldemortConfig.PUSH_HA_STATE_AUTO_CLEANUP + "=true, so the server will attempt to delete the HA state for this node, if any.");
                FailedFetchLock failedFetchLock = null;
                try {
                    failedFetchLock = FailedFetchLock.getLock(getVoldemortConfig(), new Props());
                    failedFetchLock.removeObsoleteStateForNode(getVoldemortConfig().getNodeId());
                    logger.info("Successfully ensured that the BnP HA shared state is cleared for this node.");
                } catch (ClassNotFoundException e) {
                    return new ReadOnlyStoreStatusValidation(true, new VoldemortException("Failed to find FailedFetchLock class!", e));
                } catch (Exception e) {
                    return new ReadOnlyStoreStatusValidation(true, new VoldemortException("Exception while trying to remove obsolete HA state!", e));
                } finally {
                    IOUtils.closeQuietly(failedFetchLock);
                }
            } else {
                logger.info(VoldemortConfig.PUSH_HA_STATE_AUTO_CLEANUP + "=false, so the server will NOT attempt to delete the HA state for this node, if any.");
            }
            logger.info("No Read-Only stores are disabled. Going online as planned.");
            return new ReadOnlyStoreStatusValidation(true, null);
        } else {
            // OMG, there are disabled stores!
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("Cannot go online, because the following Read-Only stores have some disabled version(s): ");
            boolean firstItem = true;
            for (String storeName : storesWithDisabledVersions) {
                if (firstItem) {
                    firstItem = false;
                } else {
                    stringBuilder.append(", ");
                }
                stringBuilder.append(storeName);
            }
            return new ReadOnlyStoreStatusValidation(false, new VoldemortException(stringBuilder.toString()));
        }
    }
}
Also used : StoreVersionManager(voldemort.store.readonly.StoreVersionManager) StorageEngine(voldemort.store.StorageEngine) ConfigurationStorageEngine(voldemort.store.configuration.ConfigurationStorageEngine) ReadOnlyStorageEngine(voldemort.store.readonly.ReadOnlyStorageEngine) Props(voldemort.utils.Props) VoldemortException(voldemort.VoldemortException) DisabledStoreException(voldemort.store.DisabledStoreException) VoldemortException(voldemort.VoldemortException) VoldemortApplicationException(voldemort.VoldemortApplicationException) UnknownHostException(java.net.UnknownHostException) FailedFetchLock(voldemort.store.readonly.swapper.FailedFetchLock)

Example 85 with VoldemortException

use of voldemort.VoldemortException in project voldemort by voldemort.

the class HttpService method startInner.

@Override
public void startInner() {
    try {
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setLowResourceMaxIdleTime(3000);
        connector.setPort(this.port);
        connector.setReuseAddress(true);
        QueuedThreadPool threadPool = new QueuedThreadPool();
        threadPool.setName("VoldemortHttp");
        threadPool.setMaxThreads(this.numberOfThreads);
        Server httpServer = new Server();
        httpServer.setConnectors(new Connector[] { connector });
        httpServer.setThreadPool(threadPool);
        httpServer.setSendServerVersion(false);
        httpServer.setSendDateHeader(false);
        Context context = new Context(httpServer, "/", Context.NO_SESSIONS);
        context.setAttribute(VoldemortServletContextListener.SERVER_KEY, server);
        context.setAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY, velocityEngine);
        context.addServlet(new ServletHolder(new AdminServlet(server, velocityEngine)), "/admin");
        context.addServlet(new ServletHolder(new StoreServlet(requestHandler)), "/stores");
        context.addServlet(new ServletHolder(new ReadOnlyStoreManagementServlet(server, velocityEngine)), "/read-only/mgmt");
        context.addServlet(new ServletHolder(new StatusServlet(server, velocityEngine)), "/server-status");
        this.context = context;
        this.httpServer = httpServer;
        this.httpServer.start();
        logger.info("HTTP service started on port " + this.port);
    } catch (Exception e) {
        String errorMessage = " Error starting service on port " + this.port;
        throw new VoldemortException(errorMessage, e);
    }
}
Also used : Context(org.mortbay.jetty.servlet.Context) StatusServlet(voldemort.server.http.gui.StatusServlet) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) AdminServlet(voldemort.server.http.gui.AdminServlet) Server(org.mortbay.jetty.Server) VoldemortServer(voldemort.server.VoldemortServer) QueuedThreadPool(org.mortbay.thread.QueuedThreadPool) ServletHolder(org.mortbay.jetty.servlet.ServletHolder) ReadOnlyStoreManagementServlet(voldemort.server.http.gui.ReadOnlyStoreManagementServlet) VoldemortException(voldemort.VoldemortException) VoldemortException(voldemort.VoldemortException)

Aggregations

VoldemortException (voldemort.VoldemortException)247 IOException (java.io.IOException)63 ByteArray (voldemort.utils.ByteArray)52 File (java.io.File)46 Node (voldemort.cluster.Node)42 StoreDefinition (voldemort.store.StoreDefinition)39 Versioned (voldemort.versioning.Versioned)38 ArrayList (java.util.ArrayList)34 Test (org.junit.Test)30 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)26 List (java.util.List)21 HashMap (java.util.HashMap)20 Cluster (voldemort.cluster.Cluster)20 VectorClock (voldemort.versioning.VectorClock)16 NoSuchCapabilityException (voldemort.store.NoSuchCapabilityException)15 ReadOnlyStorageEngine (voldemort.store.readonly.ReadOnlyStorageEngine)14 ExecutionException (java.util.concurrent.ExecutionException)13 StoreDefinitionsMapper (voldemort.xml.StoreDefinitionsMapper)13 Map (java.util.Map)12 Path (org.apache.hadoop.fs.Path)12