Search in sources :

Example 31 with VertexiumException

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);
    }
}
Also used : VertexiumException(org.vertexium.VertexiumException)

Example 32 with VertexiumException

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();
    }
}
Also used : Deflater(java.util.zip.Deflater) ByteArrayOutputStream(java.io.ByteArrayOutputStream) VertexiumException(org.vertexium.VertexiumException) VertexiumException(org.vertexium.VertexiumException)

Example 33 with VertexiumException

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();
    }
}
Also used : VertexiumException(org.vertexium.VertexiumException) VertexiumException(org.vertexium.VertexiumException)

Example 34 with VertexiumException

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);
}
Also used : CypherCompilerContext(org.vertexium.cypher.ast.CypherCompilerContext) InputStream(java.io.InputStream) VertexiumException(org.vertexium.VertexiumException) Given(cucumber.api.java.en.Given)

Aggregations

VertexiumException (org.vertexium.VertexiumException)34 Aggregation (org.elasticsearch.search.aggregations.Aggregation)6 MultiBucketsAggregation (org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)3 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 DataTableRowKey (org.vertexium.accumulo.keys.DataTableRowKey)3 StreamingPropertyValue (org.vertexium.property.StreamingPropertyValue)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 List (java.util.List)2 ScannerBase (org.apache.accumulo.core.client.ScannerBase)2 Span (org.apache.accumulo.core.trace.Span)2 GeoHashGrid (org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGrid)2 InternalGeoHashGrid (org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid)2 Histogram (org.elasticsearch.search.aggregations.bucket.histogram.Histogram)2 InternalDateHistogram (org.elasticsearch.search.aggregations.bucket.histogram.InternalDateHistogram)2 InternalHistogram (org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram)2