@Override public Connection getConnection() throws PersistenceException { try { return this.factory.getConnection(); } catch (SQLException e) { throw new PersistenceException(e); } }
private Object unmarshall(byte[] bytes) { try { return this.ctx.getMarshaller().objectFromByteBuffer(bytes); } catch (IOException | ClassNotFoundException e) { throw new PersistenceException(e); } }
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 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 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); } }
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); } } }
@SuppressWarnings("unchecked") private K resolveKey(final Object key) { if (key instanceof byte[]) { throw new PersistenceException("Cannot resolve " + getCacheName() + " cache key from byte[], enable compatibility mode"); } return (K)key; }
@SuppressWarnings("unchecked") private K resolveKey(final Object key) { if (key instanceof byte[]) { throw new PersistenceException("Cannot resolve " + getCacheName() + " cache key from byte[], enable compatibility mode"); } return (K)key; }
@SuppressWarnings("unchecked") private <T> T unmarshall(InputStream inputStream) throws PersistenceException { try { return (T) marshaller.objectFromInputStream(inputStream); } catch (IOException e) { log.ioErrorUnmarshalling(e); throw new PersistenceException("I/O error while unmarshalling from stream", e); } catch (ClassNotFoundException e) { log.unexpectedClassNotFoundException(e); throw new PersistenceException("*UNEXPECTED* ClassNotFoundException. This should not happen as Bucket class exists", e); } }
public final org.infinispan.persistence.spi.PersistenceException errorReadingFileStore(final java.lang.String arg0, final long arg1) { org.infinispan.persistence.spi.PersistenceException result = new org.infinispan.persistence.spi.PersistenceException(java.lang.String.format(errorReadingFileStore$str(), arg0, arg1)); java.lang.StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(java.util.Arrays.copyOfRange(st, 1, st.length)); return result; }
private Object unmarshall(byte[] bytes) { try { return this.ctx.getMarshaller().objectFromByteBuffer(bytes); } catch (IOException | ClassNotFoundException e) { throw new PersistenceException(e); } }
@Override public void clear() { Loggers.SQL_LOG.trace("[IS0123] SQL store: Clearing {} records", getCacheName()); int numDeleted; try { numDeleted = sql.deleteFrom(table(sqlRecordTransformer.getTableName())).execute(); } catch (Exception e) { Loggers.SQL_LOG.error("[IS0124] {}: {}", e.getMessage(), e); throw new PersistenceException(e.getMessage(), e); } Loggers.SQL_LOG.info("[IS0125] SQL store: Cleared {} {} records", numDeleted, sqlRecordTransformer.getTableName()); }
@Override public final PersistenceException prepareTxFailure(final Throwable e) { final PersistenceException result = new PersistenceException(String.format(getLoggingLocale(), prepareTxFailure$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final PersistenceException exceptionInCacheLoader(final Exception e) { final PersistenceException result = new PersistenceException(String.format(getLoggingLocale(), exceptionInCacheLoader$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final PersistenceException cannotOpenIndex(final String location, final IOException e) { final PersistenceException result = new PersistenceException(String.format(getLoggingLocale(), cannotOpenIndex$str(), location), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String interruptedWhileStopping = "ISPN029014: Interrupted while stopping the store";
@Override public final PersistenceException sizeCalculationInterrupted(final InterruptedException e) { final PersistenceException result = new PersistenceException(String.format(getLoggingLocale(), sizeCalculationInterrupted$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } @Override
@Override public final PersistenceException interruptedWhileStopping(final InterruptedException e) { final PersistenceException result = new PersistenceException(String.format(getLoggingLocale(), interruptedWhileStopping$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String interruptedWhileClearing = "ISPN029015: Interrupted while pausing the index for clear.";
@Override public final PersistenceException cannotClearData(final IOException e) { final PersistenceException result = new PersistenceException(String.format(getLoggingLocale(), cannotClearData$str()), e); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String keyIsTooLong = "ISPN029018: The serialized form of key %s is too long (%d); with maxNodeSize=%d bytes you can use only keys serialized to at most %d bytes.";
private void assertRunning() { if (!running) throw new IllegalLifecycleStateException(); if (!available) throw new PersistenceException(); } }
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); } }