Java Code Examples for org.rocksdb.RocksDBException#printStackTrace()

The following examples show how to use org.rocksdb.RocksDBException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionDBTest.java    From nuls-v2 with MIT License 6 votes vote down vote up
@Test
public void testTransactionDB() {
    initTest();
    Transaction tx = null;
    try {
        tx = TransactionDBManager.openSession(tableName);
        String value1 = "value2";
        put(key.getBytes(), value1.getBytes());

        Integer.parseInt("s");
    } catch (Exception e) {
        if(tx != null) {
            try {
                TransactionDBManager.rollBack(tx);
            } catch (RocksDBException ex) {
                ex.printStackTrace();
            }
        }
        e.printStackTrace();
    }
}
 
Example 2
Source File: RocksDBSegmentStore.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public void persist() {
    try {
        db.flush(new FlushOptions());
    } catch (RocksDBException e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: RocksDBWrapper.java    From aion with MIT License 5 votes vote down vote up
@Override
public void compact() {
    LOG.info("Compacting " + this.toString() + ".");
    try {
        db.compactRange(new byte[] {(byte) 0x00}, new byte[] {(byte) 0xff});
    } catch (RocksDBException e) {
        LOG.error("Cannot compact data.");
        e.printStackTrace();
    }
}
 
Example 4
Source File: RocksDBStorageEngine.java    From HaloDB with Apache License 2.0 5 votes vote down vote up
@Override
public void put(byte[] key, byte[] value) {
    try {
        db.put(writeOptions, key, value);
    } catch (RocksDBException e) {
        e.printStackTrace();
    }

}
 
Example 5
Source File: RocksDBStorageEngine.java    From HaloDB with Apache License 2.0 5 votes vote down vote up
@Override
public byte[] get(byte[] key) {
    byte[] value = null;
    try {
        value = db.get(key);
    } catch (RocksDBException e) {
        e.printStackTrace();
    }

    return value;
}
 
Example 6
Source File: DbInitConfig.java    From md_blockchain with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnProperty("db.rocksDB")
public RocksDB rocksDB() {
    RocksDB.loadLibrary();

    Options options = new Options().setCreateIfMissing(true);
    try {
        return RocksDB.open(options, "./rocksDB");
    } catch (RocksDBException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 7
Source File: DBManage.java    From fiery with Apache License 2.0 5 votes vote down vote up
public DBSharder getDB(Long timestamp) {
    try {

        Long timeshard = DateTimeHelper.getTimesMorning(timestamp);

        //log.info("timestamp:" + timestamp + " shard:" + timeshard + " befor:" + DateTimeHelper.getBeforeDay(fieryConfig.getKeepdataday()));
        if (timeshard > DateTimeHelper.getBeforeDay(fieryConfig.getKeepdataday())
                && timeshard <= DateTimeHelper.getCurrentTime()) {

            if (dbSharderList.containsKey(timeshard)) {
                return dbSharderList.get(timeshard);
            }

            dbSharderList.put(timeshard, new DBSharder(fieryConfig.getDbpath(), timeshard));
            return dbSharderList.get(timeshard);

        } else {
            log.info("out of the date:" + timeshard);
            return null;
        }

    } catch (RocksDBException e) {
        e.printStackTrace();
        log.error(e.getMessage());
        return null;
    }

}
 
Example 8
Source File: Webapp.java    From outbackcdx with Apache License 2.0 5 votes vote down vote up
Response changeFeed(Web.Request request) throws Web.ResponseException, IOException {
    String collection = request.param("collection");
    long since = Long.parseLong(request.param("since", "0"));
    long size = 10*1024*1024;
    if (request.param("size") != null) {
        size = Long.parseLong(request.param("size"));
    }

    final Index index = getIndex(request);

    if (verbose) {
        out.println(String.format("%s Received request %s. Retrieving deltas for collection <%s> since sequenceNumber %s", new Date(), request, collection, since));
    }

    try {
        /* This method must not close logReader, or you will get a segfault.
         * The response payload stream class ChangeFeedJsonStream closes it
         * when it's finished with it. */
        TransactionLogIterator logReader = index.getUpdatesSince(since);

        ChangeFeedJsonStream streamer = new ChangeFeedJsonStream(logReader, size);
        Response response = new Response(OK, "application/json", streamer);
        response.addHeader("Access-Control-Allow-Origin", "*");
        return response;
    } catch (RocksDBException e) {
        System.err.println(new Date() + " " + request.method() + " " + request.url() + " - " + e);
        if (!"Requested sequence not yet written in the db".equals(e.getMessage())) {
            e.printStackTrace();
        }
        throw new Web.ResponseException(
                new Response(Status.INTERNAL_ERROR, "text/plain", e.toString() + "\n"));
    }
}
 
Example 9
Source File: Webapp.java    From outbackcdx with Apache License 2.0 5 votes vote down vote up
private Response collectionDetails(RocksDB db) {
    String page = "<form>URL: <input name=url type=url><button type=submit>Query</button></form>\n<pre>";
    try {
        page += db.getProperty("rocksdb.stats");
        page += "\nEstimated number of records: " + db.getLongProperty("rocksdb.estimate-num-keys");
    } catch (RocksDBException e) {
        page += e.toString();
        e.printStackTrace();
    }
    return new Response(OK, "text/html", page);
}
 
Example 10
Source File: RocksDBSegmentStore.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public void persist() {
    try {
        db.flush(new FlushOptions());
    } catch (RocksDBException e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: RocksDBStorageEngine.java    From HaloDB with Apache License 2.0 4 votes vote down vote up
@Override
public void open() {
    options = new Options().setCreateIfMissing(true);
    options.setStatsDumpPeriodSec(1000000);

    options.setWriteBufferSize(128l * 1024 * 1024);
    options.setMaxWriteBufferNumber(3);
    options.setMaxBackgroundCompactions(20);

    Env env = Env.getDefault();
    env.setBackgroundThreads(20, Env.COMPACTION_POOL);
    options.setEnv(env);

    // max size of L1 10 MB.
    options.setMaxBytesForLevelBase(10485760);
    options.setTargetFileSizeBase(67108864);

    options.setLevel0FileNumCompactionTrigger(4);
    options.setLevel0SlowdownWritesTrigger(6);
    options.setLevel0StopWritesTrigger(12);
    options.setNumLevels(6);
    options.setDeleteObsoleteFilesPeriodMicros(300000000);


    options.setAllowMmapReads(false);
    options.setCompressionType(CompressionType.SNAPPY_COMPRESSION);


    System.out.printf("maxBackgroundCompactions %d \n", options.maxBackgroundCompactions());
    System.out.printf("minWriteBufferNumberToMerge %d \n", options.minWriteBufferNumberToMerge());
    System.out.printf("maxWriteBufferNumberToMaintain %d \n", options.maxWriteBufferNumberToMaintain());


    System.out.printf("level0FileNumCompactionTrigger %d \n", options.level0FileNumCompactionTrigger());
    System.out.printf("maxBytesForLevelBase %d \n", options.maxBytesForLevelBase());
    System.out.printf("maxBytesForLevelMultiplier %f \n", options.maxBytesForLevelMultiplier());
    System.out.printf("targetFileSizeBase %d \n", options.targetFileSizeBase());
    System.out.printf("targetFileSizeMultiplier %d \n", options.targetFileSizeMultiplier());

    List<CompressionType> compressionLevels =
        Arrays.asList(
            CompressionType.NO_COMPRESSION,
            CompressionType.NO_COMPRESSION,
            CompressionType.SNAPPY_COMPRESSION,
            CompressionType.SNAPPY_COMPRESSION,
            CompressionType.SNAPPY_COMPRESSION,
            CompressionType.SNAPPY_COMPRESSION
        );

    options.setCompressionPerLevel(compressionLevels);

    System.out.printf("compressionPerLevel %s \n", options.compressionPerLevel());
    System.out.printf("numLevels %s \n", options.numLevels());

    writeOptions = new WriteOptions();
    writeOptions.setDisableWAL(true);

    System.out.printf("WAL is disabled - %s \n", writeOptions.disableWAL());

    try {
        db = RocksDB.open(options, dbDirectory.getPath());
    } catch (RocksDBException e) {
        e.printStackTrace();
    }

}