@Override public byte[] serialize(Object obj) throws IOException { try { return marshaller.objectToByteBuffer(obj); } catch (InterruptedException e) { if (log.isTraceEnabled()) log.trace("Interrupted while serializing object"); Thread.currentThread().interrupt(); throw new IOException(e); } }
private byte[] marshall(InternalCacheEntry entry) throws IOException, InterruptedException { return getMarshaller().objectToByteBuffer(entry.toInternalCacheValue()); }
@Override public void objectToEntry(InternalCacheEntry object, DatabaseEntry entry) { byte[] b; try { b = m.objectToByteBuffer(object); } catch (IOException e) { throw new RuntimeExceptionWrapper(e); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); throw new RuntimeExceptionWrapper(ie); } entry.setData(b); } }
@Override public void updateBucket(Bucket b) throws CacheLoaderException { File f = new File(root, b.getBucketIdAsString()); if (f.exists()) { if (!purgeFile(f)) { log.problemsRemovingFile(f); } else if (trace) { log.tracef("Successfully deleted file: '%s'", f.getName()); } } if (!b.getEntries().isEmpty()) { try { byte[] bytes = marshaller.objectToByteBuffer(b); fileSync.write(bytes, f); } catch (IOException ex) { log.errorSavingBucket(b, ex); throw new CacheLoaderException(ex); } catch (InterruptedException ie) { if (trace) { log.trace("Interrupted while marshalling a bucket"); } Thread.currentThread().interrupt(); // Restore interrupted status } } }