Search in sources :

Example 1 with BinaryPackedObjects

use of org.locationtech.geogig.remote.BinaryPackedObjects in project GeoGig by boundlessgeo.

the class SendObjectResource method post.

@Override
public void post(Representation entity) {
    InputStream input = null;
    Request request = getRequest();
    try {
        LOGGER.info("Receiving objects from {}", request.getClientInfo().getAddress());
        Representation representation = request.getEntity();
        input = representation.getStream();
        final GeoGIG ggit = getGeogig(request).get();
        final BinaryPackedObjects unpacker = new BinaryPackedObjects(ggit.getRepository().objectDatabase());
        CountingInputStream countingStream = new CountingInputStream(input);
        Stopwatch sw = Stopwatch.createStarted();
        IngestResults ingestResults = unpacker.ingest(countingStream);
        sw.stop();
        LOGGER.info(String.format("SendObjectResource: Processed %,d objects.\nInserted: %,d.\nExisting: %,d.\nTime to process: %s.\nStream size: %,d bytes.\n", ingestResults.total(), ingestResults.getInserted(), ingestResults.getExisting(), sw, countingStream.getCount()));
    } catch (IOException e) {
        LOGGER.warn("Error processing incoming objects from {}", request.getClientInfo().getAddress(), e);
        throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL, e);
    } finally {
        if (input != null)
            Closeables.closeQuietly(input);
    }
}
Also used : CountingInputStream(com.google.common.io.CountingInputStream) InputStream(java.io.InputStream) RestletException(org.locationtech.geogig.rest.RestletException) Request(org.restlet.data.Request) CountingInputStream(com.google.common.io.CountingInputStream) Stopwatch(com.google.common.base.Stopwatch) Representation(org.restlet.resource.Representation) IngestResults(org.locationtech.geogig.remote.BinaryPackedObjects.IngestResults) IOException(java.io.IOException) GeoGIG(org.locationtech.geogig.api.GeoGIG) BinaryPackedObjects(org.locationtech.geogig.remote.BinaryPackedObjects)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)1 CountingInputStream (com.google.common.io.CountingInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 GeoGIG (org.locationtech.geogig.api.GeoGIG)1 BinaryPackedObjects (org.locationtech.geogig.remote.BinaryPackedObjects)1 IngestResults (org.locationtech.geogig.remote.BinaryPackedObjects.IngestResults)1 RestletException (org.locationtech.geogig.rest.RestletException)1 Request (org.restlet.data.Request)1 Representation (org.restlet.resource.Representation)1