本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.marshal方法的典型用法代码示例。如果您正苦于以下问题:Java U.marshal方法的具体用法?Java U.marshal怎么用?Java U.marshal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.typedef.internal.U
的用法示例。
在下文中一共展示了U.marshal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: marshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public ByteBuffer marshal(Object obj, int off) throws IOException {
try {
if (!(obj instanceof GridClientMessage))
throw new IOException("Message serialization of given type is not supported: " +
obj.getClass().getName());
byte[] marshBytes = U.marshal(opMarsh, obj);
boolean zip = marshBytes.length > 512;
byte[] bytes = zip ? zipBytes(marshBytes) : marshBytes;
ByteBuffer buf = ByteBuffer.allocate(off + bytes.length + 1);
buf.position(off);
buf.put((byte)(zip ? 1 : 0));
buf.put(bytes);
buf.flip();
return buf;
}
catch (IgniteCheckedException e) {
throw new IOException(e);
}
}
示例2: marshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public ByteBuffer marshal(Object obj, int off) throws IOException {
try {
if (!(obj instanceof GridClientMessage))
throw new IOException("Message serialization of given type is not supported: " +
obj.getClass().getName());
byte[] bytes = U.marshal(opMarsh, obj);
ByteBuffer buf = ByteBuffer.allocate(off + bytes.length);
buf.position(off);
buf.put(bytes);
buf.flip();
return buf;
}
catch (IgniteCheckedException e) {
throw new IOException(e);
}
}
示例3: prepareMarshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc}
* @param ctx*/
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (missedKeys != null)
prepareMarshalCacheObjects(missedKeys, cctx);
if (infos != null) {
for (GridCacheEntryInfo info : infos)
info.marshal(cctx.cacheObjectContext());
}
if (err != null && errBytes == null)
errBytes = U.marshal(ctx, err);
}
示例4: prepareMarshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param ctx Cache context.
* @throws IgniteCheckedException If failed.
*/
public void prepareMarshal(GridCacheContext ctx) throws IgniteCheckedException {
key.prepareMarshal(ctx.cacheObjectContext());
if (err != null && errBytes == null) {
try {
errBytes = U.marshal(ctx.marshaller(), err);
}
catch (IgniteCheckedException e) {
// Try send exception even if it's unable to marshal.
IgniteCheckedException exc = new IgniteCheckedException(err.getMessage());
exc.setStackTrace(err.getStackTrace());
exc.addSuppressed(e);
errBytes = U.marshal(ctx.marshaller(), exc);
}
}
if (res != null)
res.prepareMarshal(ctx.cacheObjectContext());
}
示例5: writeMetadata
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param binMeta Binary metadata to be written to disk.
*/
void writeMetadata(BinaryMetadata binMeta) {
if (!CU.isPersistenceEnabled(ctx.config()))
return;
try {
File file = new File(workDir, Integer.toString(binMeta.typeId()) + ".bin");
try(FileOutputStream out = new FileOutputStream(file, false)) {
byte[] marshalled = U.marshal(ctx, binMeta);
out.write(marshalled);
}
}
catch (Exception e) {
U.warn(log, "Failed to save metadata for typeId: " + binMeta.typeId() +
"; exception was thrown: " + e.getMessage());
}
}
示例6: prepareMarshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
if (res != null) {
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (res instanceof CacheObject)
prepareMarshalCacheObject((CacheObject) res, cctx);
else if (res instanceof CacheVersionedValue)
((CacheVersionedValue)res).prepareMarshal(cctx.cacheObjectContext());
else if (res instanceof GridCacheEntryInfo)
((GridCacheEntryInfo)res).marshal(cctx);
}
if (err != null && errBytes == null)
errBytes = U.marshal(ctx, err);
}
示例7: marshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Marshal object.
*
* @param obj Object to marshal.
* @return Binary data.
* @throws IOException If marshaling failed.
*/
@Nullable private byte[] marshal(final Object obj) throws IOException {
if (marsh != null) {
try {
return U.marshal(marsh, obj);
}
catch (IgniteCheckedException e) {
throw new IOException(e);
}
}
return null;
}
示例8: h2Serializer
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @return Serializer.
*/
private JavaObjectSerializer h2Serializer() {
return new JavaObjectSerializer() {
@Override public byte[] serialize(Object obj) throws Exception {
return U.marshal(marshaller, obj);
}
@Override public Object deserialize(byte[] bytes) throws Exception {
ClassLoader clsLdr = ctx != null ? U.resolveClassLoader(ctx.config()) : null;
return U.unmarshal(marshaller, bytes, clsLdr);
}
};
}
示例9: valueBytes
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public byte[] valueBytes(CacheObjectValueContext cacheCtx) throws IgniteCheckedException {
if (valBytes != null)
return valBytes;
valBytes = U.marshal(ctx.marshaller(), this);
return valBytes;
}
示例10: prepareMarshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc}
* @param ctx*/
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId));
if (err != null && errBytes == null)
errBytes = U.marshal(ctx.marshaller(), err);
}
示例11: AddressResponse
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* @param addrs Addresses discovery SPI binds to.
* @throws IgniteCheckedException If marshalling failed.
*/
private AddressResponse(Collection<InetSocketAddress> addrs) throws IgniteCheckedException {
this.addrs = addrs;
byte[] addrsData = U.marshal(marsh, addrs);
data = new byte[U.IGNITE_HEADER.length + addrsData.length];
if (data.length > MAX_DATA_LENGTH)
throw new IgniteCheckedException("Too long data packet [size=" + data.length + ", max=" + MAX_DATA_LENGTH + "]");
System.arraycopy(U.IGNITE_HEADER, 0, data, 0, U.IGNITE_HEADER.length);
System.arraycopy(addrsData, 0, data, 4, addrsData.length);
}
示例12: prepareMarshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc}
* @param ctx*/
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);
GridCacheContext cctx = ctx.cacheContext(cacheId);
if (entries != null) {
for (GridCacheEntryInfo info : entries)
info.marshal(cctx);
}
if (err != null && errBytes == null)
errBytes = U.marshal(ctx, err);
}
示例13: prepareMarshal
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
super.prepareMarshal(marsh);
if (err != null)
errBytes = U.marshal(marsh, err);
}
示例14: start
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
if (ctx.config().isDaemon())
return;
marshErrBytes = U.marshal(marsh, new IgniteCheckedException("Failed to marshal response error, " +
"see node log for details."));
flusher = new IgniteThread(new GridWorker(ctx.igniteInstanceName(), "grid-data-loader-flusher", log) {
@Override protected void body() throws InterruptedException {
while (!isCancelled()) {
DataStreamerImpl<K, V> ldr = flushQ.take();
if (!busyLock.enterBusy())
return;
try {
if (ldr.isClosed())
continue;
ldr.tryFlush();
flushQ.offer(ldr);
}
finally {
busyLock.leaveBusy();
}
}
}
});
flusher.start();
if (log.isDebugEnabled())
log.debug("Started data streamer processor.");
}
示例15: serialize
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public byte[] serialize(String topic, CacheEvent event) {
try {
return U.marshal(marsh, event);
}
catch (IgniteCheckedException e) {
throw new SerializationException("Failed to serialize cache event!", e);
}
}