use of voldemort.VoldemortException in project voldemort by voldemort.
the class ReadOnlyStoreFetchOperation method operate.
@Override
public void operate() {
this.currentState = State.RUNNING;
File fetchDir = null;
if (fileFetcher == null) {
logger.warn("File fetcher class has not instantiated correctly. Assuming local file");
if (!Utils.isReadableDir(fetchUrl)) {
throw new VoldemortException("Fetch url " + fetchUrl + " is not readable");
}
fetchDir = new File(store.getStoreDirPath(), "version-" + Long.toString(pushVersion));
if (fetchDir.exists())
throw new VoldemortException("Version directory " + fetchDir.getAbsolutePath() + " already exists");
Utils.move(new File(fetchUrl), fetchDir);
} else {
logger.info("Started executing fetch of " + fetchUrl + " for RO store '" + storeName + "' version " + pushVersion);
updateStatus("0 MB copied at 0 MB/sec - 0 % complete");
try {
String destinationDir = store.getStoreDirPath() + File.separator + "version-" + Long.toString(pushVersion);
fetchDir = fileFetcher.fetch(fetchUrl, destinationDir, status, storeName, pushVersion, metadataStore, diskQuotaSizeInKB);
if (fetchDir == null) {
String errorMessage = "File fetcher failed for " + fetchUrl + " and store '" + storeName + "' due to incorrect input path/checksum error";
updateStatus(errorMessage);
logger.error(errorMessage);
throw new VoldemortException(errorMessage);
} else {
String message = "Successfully executed fetch of " + fetchUrl + " for RO store '" + storeName + "'";
updateStatus(message);
logger.info(message);
}
} catch (VoldemortException ve) {
String errorMessage = "File fetcher failed for " + fetchUrl + " and store '" + storeName + "' Reason: \n" + ve.getMessage();
updateStatus(errorMessage);
logger.error(errorMessage, ve);
throw ve;
} catch (Exception e) {
throw new VoldemortException("Exception in Fetcher = " + e.getMessage(), e);
}
}
fetchDirPath = fetchDir.getAbsolutePath();
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class UpdateSlopEntriesRequestHandler method handleRequest.
public StreamRequestHandlerState handleRequest(DataInputStream inputStream, DataOutputStream outputStream) throws IOException {
if (!metadataStore.getSlopStreamingEnabledUnlocked()) {
throw new SlopStreamingDisabledException("Slop streaming is disabled on node " + metadataStore.getNodeId() + " under " + metadataStore.getServerStateUnlocked() + " state.");
}
long startNs = System.nanoTime();
if (request == null) {
int size = 0;
try {
size = inputStream.readInt();
} catch (EOFException e) {
if (logger.isTraceEnabled())
logger.trace("Incomplete read for message size");
networkTimeNs += System.nanoTime() - startNs;
return StreamRequestHandlerState.INCOMPLETE_READ;
}
if (size == -1) {
if (logger.isTraceEnabled())
logger.trace("Message size -1, completed slop update");
return StreamRequestHandlerState.COMPLETE;
}
if (logger.isTraceEnabled())
logger.trace("UpdateSlopEntriesRequest message size: " + size);
byte[] input = new byte[size];
try {
ByteUtils.read(inputStream, input);
networkTimeNs += Utils.elapsedTimeNs(startNs, System.nanoTime());
} catch (EOFException e) {
if (logger.isTraceEnabled())
logger.trace("Incomplete read for message");
return StreamRequestHandlerState.INCOMPLETE_READ;
}
VAdminProto.UpdateSlopEntriesRequest.Builder builder = VAdminProto.UpdateSlopEntriesRequest.newBuilder();
builder.mergeFrom(input);
request = builder.build();
}
StorageEngine<ByteArray, byte[], byte[]> storageEngine = AdminServiceRequestHandler.getStorageEngine(storeRepository, request.getStore());
StreamingStats streamStats = null;
if (isJmxEnabled) {
streamStats = storeRepository.getStreamingStats(storageEngine.getName());
streamStats.reportNetworkTime(Operation.SLOP_UPDATE, networkTimeNs);
}
networkTimeNs = 0;
ByteArray key = ProtoUtils.decodeBytes(request.getKey());
VectorClock vectorClock = ProtoUtils.decodeClock(request.getVersion());
switch(request.getRequestType()) {
case PUT:
try {
// Retrieve the transform if its exists
byte[] transforms = null;
if (request.hasTransform()) {
transforms = ProtoUtils.decodeBytes(request.getTransform()).get();
}
// Retrieve the value
byte[] value = ProtoUtils.decodeBytes(request.getValue()).get();
startNs = System.nanoTime();
storageEngine.put(key, Versioned.value(value, vectorClock), transforms);
if (isJmxEnabled)
streamStats.reportStorageTime(Operation.SLOP_UPDATE, Utils.elapsedTimeNs(startNs, System.nanoTime()));
if (logger.isTraceEnabled())
logger.trace("updateSlopEntries (Streaming put) successful on key:" + key + " of store: " + request.getStore());
} catch (ObsoleteVersionException e) {
// log and ignore
if (logger.isDebugEnabled())
logger.debug("updateSlopEntries (Streaming put) threw ObsoleteVersionException, Ignoring.");
}
break;
case DELETE:
try {
startNs = System.nanoTime();
storageEngine.delete(key, vectorClock);
if (isJmxEnabled)
streamStats.reportStorageTime(Operation.SLOP_UPDATE, System.nanoTime() - startNs);
if (logger.isTraceEnabled())
logger.trace("updateSlopEntries (Streaming delete) successful");
} catch (ObsoleteVersionException e) {
// log and ignore
if (logger.isDebugEnabled())
logger.debug("updateSlopEntries (Streaming delete) threw ObsoleteVersionException, Ignoring.");
}
break;
default:
throw new VoldemortException("Unsupported operation ");
}
// log progress
counter++;
if (isJmxEnabled)
streamStats.reportStreamingPut(Operation.SLOP_UPDATE);
if (0 == counter % 100000) {
long totalTime = (System.currentTimeMillis() - startTime) / 1000;
if (logger.isDebugEnabled())
logger.debug("updateSlopEntries() updated " + counter + " entries in " + totalTime + " s");
}
request = null;
return StreamRequestHandlerState.READING;
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class BdbNativeBackup method determineLastFile.
private Long determineLastFile(File backupDir, final AsyncOperationStatus status) {
status.setStatus("Determining the last backed up file...");
System.out.println("Backup directory is \'" + backupDir.getPath() + "\'.");
File[] backupFiles = backupDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
if (!name.endsWith(BDB_EXT)) {
return false;
}
String part = name.substring(0, name.length() - BDB_EXT.length());
try {
Long.parseLong(part, 16);
} catch (NumberFormatException nfe) {
status.setStatus("Warning: " + BDB_EXT + " file whose name is not a number, ignoring: " + name);
return false;
}
return true;
}
});
if (backupFiles == null) {
throw new VoldemortException("Failed to read backup directory. Please check" + "if the directory exists, or permission is granted.");
}
if (backupFiles.length == 0) {
status.setStatus("No backup files found, assuming a full backup is required.");
return null;
}
long largest = Long.MIN_VALUE;
for (File file : backupFiles) {
long value = fileNameToNumber(file.getName());
if (value > largest) {
largest = value;
}
}
status.setStatus("Last backed up file was " + largest);
return largest;
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class BdbStorageConfiguration method close.
public void close() {
synchronized (lock) {
try {
for (Environment environment : environments.values()) {
environment.sync();
environment.close();
}
} catch (DatabaseException e) {
throw new VoldemortException(e);
}
}
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class BdbStorageConfiguration method checkPointAllEnvironments.
/**
* Forceful checkpointing
*/
@JmxOperation(description = "Forcefully checkpoint all the environments")
public void checkPointAllEnvironments() {
synchronized (lock) {
try {
for (Environment environment : environments.values()) {
CheckpointConfig checkPointConfig = new CheckpointConfig();
checkPointConfig.setForce(true);
environment.checkpoint(checkPointConfig);
}
} catch (DatabaseException e) {
throw new VoldemortException(e);
}
}
}
Aggregations