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);
}
}
}
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;
}
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;
}
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()));
}
}
}
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);
}
}
Aggregations