congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
StreamingMarshaller
Code IndexAdd Tabnine to your IDE (free)

How to use
StreamingMarshaller
in
org.infinispan.marshall

Best Java code snippets using org.infinispan.marshall.StreamingMarshaller (Showing top 13 results out of 315)

origin: org.infinispan/infinispan-cachestore-jdbm

@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);
  }
}
origin: org.infinispan/infinispan-custom52x-store

private Object objectFromInputStreamInReentrantMode(InputStream is) throws IOException, ClassNotFoundException, InterruptedException {
 int len = is.available();
 Object o = null;
 if (len != 0) {
   ExposedByteArrayOutputStream bytes = new ExposedByteArrayOutputStream(len);
   byte[] buf = new byte[Math.min(len, 1024)];
   int bytesRead;
   while ((bytesRead = is.read(buf, 0, buf.length)) != -1) {
    bytes.write(buf, 0, bytesRead);
   }
   is = new ByteArrayInputStream(bytes.getRawBuffer(), 0, bytes.size());
   ObjectInput unmarshaller = marshaller.startObjectInput(is, false);
   try {
    o = marshaller.objectFromObjectStream(unmarshaller);
   } finally {
    marshaller.finishObjectInput(unmarshaller);
   }
 }
 return o;
}
origin: org.infinispan/infinispan-cachestore-jdbm

@Override
public Object deserialize(byte[] buf) throws IOException {
  try {
    return marshaller.objectFromByteBuffer(buf);
  } catch (ClassNotFoundException e) {
    throw (IOException)new IOException().initCause(e);
  }
}
origin: org.infinispan/infinispan-custom52x-store

public void testToStream() throws Exception {
 cs.store(TestInternalCacheEntryFactory.create("k1", "v1", -1, -1));
 StreamingMarshaller marshaller = getMarshaller();
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 ObjectOutput oo = marshaller.startObjectOutput(out, false, 12);
 try {
   cs.toStream(new UnclosableObjectOutputStream(oo));
 } finally {
   marshaller.finishObjectOutput(oo);
   out.close();
 }
 ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
 ObjectInput oi = marshaller.startObjectInput(in, false);
 try {
   assert oi.readInt() == 1 : "we have 3 different buckets";
   assert oi.readObject().equals(fcs.getLockFromKey("k1") + "");
   assert oi.readInt() > 0; //size on disk
 } finally {
   marshaller.finishObjectInput(oi);
 }
}
origin: org.infinispan/infinispan-cachestore-jdbm

/**
* Reads from a stream the number of entries (long) then the entries themselves.
*/
@Override
public void fromStream(ObjectInput in) throws CacheLoaderException {
 try {
   log.debug("fromStream()");
   int count = 0;
   while (true) {
    count++;
    InternalCacheEntry entry = (InternalCacheEntry) getMarshaller().objectFromObjectStream(in);
    if (entry == null)
      break;
    store(entry);
   }
   log.debugf("read %d entries", count);
 } catch (IOException e) {
   throw new CacheLoaderException(e);
 } catch (ClassNotFoundException e) {
   throw new CacheLoaderException(e);
 } catch (InterruptedException ie) {
   if (log.isTraceEnabled()) log.trace("Interrupted while reading from stream"); 
   Thread.currentThread().interrupt();
 }
}
origin: org.infinispan/infinispan-cachestore-jdbm

/**
* Writes to a stream the number of entries (long) then the entries themselves.
*/
@Override
public void toStream(ObjectOutput out) throws CacheLoaderException {
 try {
   Set<InternalCacheEntry> loadAll = loadAll();
   log.debug("toStream() entries");
   int count = 0;
   for (InternalCacheEntry entry : loadAll) {
    getMarshaller().objectToObjectStream(entry, out);
    count++;
   }
   getMarshaller().objectToObjectStream(null, out);
   log.debugf("wrote %d entries", count);
 } catch (IOException e) {
   throw new CacheLoaderException(e);
 }
}
origin: org.infinispan/infinispan-custom52x-store

ObjectOutput oo = marshaller.startObjectOutput(out, false, 12);
try {
  cs.toStream(new UnclosableObjectOutputStream(oo));
} finally {
  marshaller.finishObjectOutput(oo);
  out.close();
ObjectInput oi = marshaller.startObjectInput(in, false);
try {
  cs.fromStream(new UnclosableObjectInputStream(oi));
} finally {
  marshaller.finishObjectInput(oi);
origin: org.infinispan/infinispan-cachestore-jdbm

private byte[] marshall(InternalCacheEntry entry) throws IOException, InterruptedException {
 return getMarshaller().objectToByteBuffer(entry.toInternalCacheValue());
}
origin: org.infinispan/infinispan-cachestore-jdbm

private InternalCacheEntry unmarshall(Object o, Object key) throws IOException, ClassNotFoundException {
 if (o == null)
   return null;
 byte b[] = (byte[]) o;
 InternalCacheValue v = (InternalCacheValue) getMarshaller().objectFromByteBuffer(b);
 return v.toInternalCacheEntry(key);
}
origin: org.infinispan/infinispan-cachestore-bdbje

  @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);
  }
}
origin: org.infinispan/infinispan-cachestore-bdbje

@Override
public InternalCacheEntry entryToObject(DatabaseEntry entry) {
 try {
   return (InternalCacheEntry) m.objectFromByteBuffer(entry.getData());
 } catch (IOException e) {
   throw new RuntimeExceptionWrapper(e);
 } catch (ClassNotFoundException e) {
   throw new RuntimeExceptionWrapper(e);
 }
}
origin: org.infinispan/infinispan-custom52x-store

@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
   }
 }
}
origin: org.infinispan/infinispan-cachestore-jdbm

if (b == null)
 continue;
InternalCacheValue ice = (InternalCacheValue) getMarshaller().objectFromByteBuffer(b);
if (ice.isExpired(currentTimeMillis)) {
org.infinispan.marshallStreamingMarshaller

Javadoc

A specialization of Marshaller that supports streams.

A single instance of any implementation is shared by multiple threads, so implementations need to be threadsafe, and preferably immutable.

Most used methods

  • objectToByteBuffer
  • finishObjectInput
    Finish using the given ObjectInput. After opening a ObjectInput and calling objectFromObjectStream()
  • objectFromByteBuffer
  • objectFromObjectStream
    Unmarshalls an object from an java.io.ObjectInput
  • startObjectInput
    Create and open a new ObjectInput for the given input stream. This method should be used for opening
  • finishObjectOutput
    Finish using the given ObjectOutput. After opening a ObjectOutput and calling objectToObjectStream()
  • objectToObjectStream
    Marshalls an object to a given java.io.ObjectOutput
  • startObjectOutput

Popular in Java

  • Creating JSON documents from java classes using gson
  • onCreateOptionsMenu (Activity)
  • putExtra (Intent)
  • addToBackStack (FragmentTransaction)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • JPanel (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now