private Object unmarshall(byte[] bytes) { try { return this.ctx.getMarshaller().objectFromByteBuffer(bytes); } catch (IOException | ClassNotFoundException e) { throw new PersistenceException(e); } }
@Override public Connection getConnection() throws PersistenceException { try { return this.factory.getConnection(); } catch (SQLException e) { throw new PersistenceException(e); } }
private MarshalledEntry<K, V> asMarshalledEntry(Object key) { return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, (Object) null, (InternalMetadata) null); }
@Override public void init(InitializationContext ctx) { this.ctx = ctx; HotRodStoreConfiguration configuration = ctx.getConfiguration(); RemoteCacheContainer remoteCacheContainer = configuration.attributes().attribute(HotRodStoreConfiguration.REMOTE_CACHE_CONTAINER).get(); String cacheConfiguration = configuration.attributes().attribute(HotRodStoreConfiguration.CACHE_CONFIGURATION).get(); String cacheName = ctx.getCache().getName(); try { ProtocolVersion protocolVersion = remoteCacheContainer.getConfiguration().version(); // Administration support was introduced in protocol version 2.7 if (protocolVersion.compareTo(ProtocolVersion.PROTOCOL_VERSION_27) < 0) { this.remoteCache = remoteCacheContainer.getCache(cacheName, false); if (this.remoteCache == null) { throw InfinispanLogger.ROOT_LOGGER.remoteCacheMustBeDefined(protocolVersion.toString(), cacheName); } } else { InfinispanLogger.ROOT_LOGGER.remoteCacheCreated(cacheName, cacheConfiguration); this.remoteCache = remoteCacheContainer.administration().getOrCreateCache(cacheName, cacheConfiguration); } } catch (HotRodClientException ex) { throw new PersistenceException(ex); } }
@Override public void init(InitializationContext initializationContext) { configuration = initializationContext.getConfiguration(); ctx = initializationContext; }
@Override public void init(InitializationContext ctx) { factory = ctx.getMarshalledEntryFactory(); timeService = ctx.getTimeService(); }
private Object unmarshall(byte[] bytes) throws IOException, ClassNotFoundException { if (bytes == null) return null; return ctx.getMarshaller().objectFromByteBuffer(bytes); }
@Override public void run() { listener.entryPurged(key); } }, null);
protected void verifyNoDataOnLoader(Cache<Object, Object> c) throws Exception { CacheLoader l = TestingUtil.getFirstLoader(c); assert !l.contains(A_B_AGE); assert !l.contains(A_B_NAME); assert !l.contains(A_C_AGE); assert !l.contains(A_C_NAME); assert !l.contains(A_D_AGE); assert !l.contains(A_D_NAME); }
private byte[] marshall(Object key) { try { return (key instanceof WrappedByteArray) ? ((WrappedByteArray) key).getBytes() : this.ctx.getMarshaller().objectToByteBuffer(key); } catch (IOException | InterruptedException e) { throw new PersistenceException(e); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { throw new PersistenceException(cause); }
@Override public void init(InitializationContext ctx) { this.config = ctx.getConfiguration(); }
@Override public MarshalledEntry<K, V> load(Object key) throws PersistenceException { byte[] bytes = this.remoteCache.get(this.marshall(key)); if (bytes == null) { return null; } Map.Entry<ByteBuffer, ByteBuffer> entry = this.unmarshallValue(bytes); return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, entry.getKey(), entry.getValue()); }
public static void verifyNoDataOnLoader(Cache<Object, Object> c) throws Exception { CacheLoader l = TestingUtil.getFirstLoader(c); assert !l.contains(A_B_AGE); assert !l.contains(A_B_NAME); assert !l.contains(A_C_AGE); assert !l.contains(A_C_NAME); assert !l.contains(A_D_AGE); assert !l.contains(A_D_NAME); }
private Object unmarshall(byte[] bytes) { try { return this.ctx.getMarshaller().objectFromByteBuffer(bytes); } catch (IOException | ClassNotFoundException e) { throw new PersistenceException(e); } }
@Override public Connection getConnection() throws PersistenceException { try { Connection connection = DriverManager.getConnection(connectionUrl, userName, password); if (connection == null) throw new PersistenceException("Received null connection from the DriverManager!"); connectionCount++; return connection; } catch (SQLException e) { throw new PersistenceException("Could not obtain a new connection", e); } }
@Override public void init(InitializationContext ctx) { this.ctx = ctx; LuceneLoaderConfiguration configuration = ctx.getConfiguration(); this.fileRoot = configuration.location(); this.autoChunkSize = configuration.autoChunkSize(); this.affinitySegmentId = configuration.affinitySegmentId(); }
private byte[] marshall(Object key) { try { return (key instanceof WrappedByteArray) ? ((WrappedByteArray) key).getBytes() : this.ctx.getMarshaller().objectToByteBuffer(key); } catch (IOException | InterruptedException e) { throw new PersistenceException(e); } }
private Map<Object, MarshalledEntry> unmarshallBucketEntries(InputStream inputStream) { try { return (Map<Object, MarshalledEntry>) marshaller.objectFromInputStream(inputStream); } catch (IOException e) { throw new PersistenceException("I/O error while unmarshalling from stream", e); } catch (ClassNotFoundException e) { throw new PersistenceException(e); } } }
private void assertRunning() { if (!running) throw new IllegalLifecycleStateException(); if (!available) throw new PersistenceException(); } }