public void remove(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { db.remove(name, key); Sync<Void> sync = Sync.create(); CacheKey memKey = ns.key(name); client.modify(singleton(Change.remove(memKey)), sync); try { sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } } }
public void remove(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { db.remove(name, key); Sync<Void> sync = Sync.create(); CacheKey memKey = ns.key(name); client.modify(singleton(Change.remove(memKey)), sync); try { sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } } }
public void putUnique(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { db.putUnique(name, key); Sync<Void> sync = Sync.create(); CacheKey memKey = ns.key(name); byte[] data = key.asBytes(); client.modify(singleton(Change.put(memKey, data)), sync); try { sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } }
public void putUnique(RepositoryName name, RepositoryKey key) throws DhtException, TimeoutException { db.putUnique(name, key); Sync<Void> sync = Sync.create(); CacheKey memKey = ns.key(name); byte[] data = key.asBytes(); client.modify(singleton(Change.put(memKey, data)), sync); try { sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } }
public RepositoryKey get(RepositoryName name) throws DhtException, TimeoutException { CacheKey memKey = ns.key(name); Sync<Map<CacheKey, byte[]>> sync = Sync.create(); client.get(singleton(memKey), sync); Map<CacheKey, byte[]> result; try { result = sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } catch (TimeoutException timeout) { // Fall through and read the database directly. result = emptyMap(); } byte[] data = result.get(memKey); if (data != null) { if (data.length == 0) return null; return RepositoryKey.fromBytes(data); } RepositoryKey key = db.get(name); data = key != null ? key.asBytes() : new byte[0]; client.modify(singleton(Change.put(memKey, data)), none); return key; }
public RepositoryKey get(RepositoryName name) throws DhtException, TimeoutException { CacheKey memKey = ns.key(name); Sync<Map<CacheKey, byte[]>> sync = Sync.create(); client.get(singleton(memKey), sync); Map<CacheKey, byte[]> result; try { result = sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException(); } catch (TimeoutException timeout) { // Fall through and read the database directly. result = emptyMap(); } byte[] data = result.get(memKey); if (data != null) { if (data.length == 0) return null; return RepositoryKey.fromBytes(data); } RepositoryKey key = db.get(name); data = key != null ? key.asBytes() : new byte[0]; client.modify(singleton(Change.put(memKey, data)), none); return key; }
/** * Update properties by setting fields from the configuration. * <p> * If a property is not defined in the configuration, then it is left * unmodified. * * @param rc * configuration to read properties from. * @return {@code this} */ public CacheOptions fromConfig(final Config rc) { setTimeout(Timeout.getTimeout(rc, "cache", "dht", "timeout", getTimeout())); setWriteBufferSize(rc.getInt("cache", "dht", "writeBufferSize", getWriteBufferSize())); return this; } }
/** * Update properties by setting fields from the configuration. * <p> * If a property is not defined in the configuration, then it is left * unmodified. * * @param rc * configuration to read properties from. * @return {@code this} */ public CacheOptions fromConfig(final Config rc) { setTimeout(Timeout.getTimeout(rc, "cache", "dht", "timeout", getTimeout())); setWriteBufferSize(rc.getInt("cache", "dht", "writeBufferSize", getWriteBufferSize())); return this; } }
result = sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException();
result = sync.get(options.getTimeout()); } catch (InterruptedException e) { throw new TimeoutException();