use of org.vertexium.VertexiumException in project vertexium by visallo.
the class KryoFactory method registerAccumuloClasses.
private void registerAccumuloClasses(Kryo kryo) {
try {
Class.forName("org.vertexium.accumulo.AccumuloGraph");
} catch (ClassNotFoundException e) {
// this is ok and expected if Accumulo is not in the classpath
return;
}
try {
kryo.register(Class.forName("org.vertexium.accumulo.iterator.model.EdgeInfo"), 1000);
kryo.register(Class.forName("org.vertexium.accumulo.StreamingPropertyValueTableRef"), 1004);
kryo.register(Class.forName("org.vertexium.accumulo.StreamingPropertyValueHdfsRef"), 1005);
} catch (ClassNotFoundException ex) {
throw new VertexiumException("Could not find accumulo classes to serialize", ex);
}
}
use of org.vertexium.VertexiumException in project vertexium by visallo.
the class QuickKryoVertexiumSerializer method compress.
protected byte[] compress(byte[] bytes) {
if (!enableCompression) {
return bytes;
}
Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION);
try {
deflater.setInput(bytes);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(bytes.length);
deflater.finish();
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
int count = deflater.deflate(buffer);
outputStream.write(buffer, 0, count);
}
outputStream.close();
return outputStream.toByteArray();
} catch (Exception ex) {
throw new VertexiumException("Could not compress bytes", ex);
} finally {
deflater.end();
}
}
use of org.vertexium.VertexiumException in project vertexium by visallo.
the class FlushObjectQueue method flush.
public void flush() {
flushLock.writeLock().lock();
try {
int sleep = 0;
while (!queue.isEmpty()) {
FlushObject flushObject = queue.remove();
try {
flushObject.getFuture().get(30, TimeUnit.SECONDS);
sleep = 0;
} catch (Exception ex) {
sleep += 10;
String message = String.format("Could not write %s", flushObject);
if (flushObject.retryCount >= MAX_RETRIES) {
throw new VertexiumException(message, ex);
}
String logMessage = String.format("%s: %s (retrying: %d/%d)", message, ex.getMessage(), flushObject.retryCount + 1, MAX_RETRIES);
if (flushObject.retryCount > 0) {
// don't log warn the first time
LOGGER.warn("%s", logMessage);
} else {
LOGGER.debug("%s", logMessage);
}
requeueFlushObject(flushObject, sleep);
}
}
} finally {
flushLock.writeLock().unlock();
}
}
use of org.vertexium.VertexiumException in project vertexium by visallo.
the class GraphGlue method givenTheBinaryTreeGraph.
@Given("^the binary-tree-(\\d+) graph$")
public void givenTheBinaryTreeGraph(int number) throws Throwable {
createGraph();
String resourceName = "/org/vertexium/cypher/tck/binary-tree-" + number + ".cyp";
InputStream treeIn = this.getClass().getResourceAsStream(resourceName);
if (treeIn == null) {
throw new VertexiumException("Could not find '" + resourceName + "'");
}
String cyp = IOUtils.toString(treeIn);
CypherCompilerContext compilerContext = new CypherCompilerContext(ctx.getFunctions());
VertexiumCypherQuery.parse(compilerContext, cyp).execute(ctx);
}
Aggregations