当前位置: 首页>>代码示例>>Java>>正文


Java U.marshal方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:27,代码来源:GridClientZipOptimizedMarshaller.java

示例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);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:GridClientOptimizedMarshaller.java

示例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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:GridDhtForceKeysResponse.java

示例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());
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:CacheInvokeDirectResult.java

示例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());
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:BinaryMetadataFileStore.java

示例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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:GridNearSingleGetResponse.java

示例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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:WebSessionV2.java

示例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);
        }
    };
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:IgniteH2Indexing.java

示例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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:10,代码来源:BinaryEnumObjectImpl.java

示例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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:GridDistributedLockResponse.java

示例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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:17,代码来源:TcpDiscoveryMulticastIpFinder.java

示例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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:16,代码来源:GridNearGetResponse.java

示例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);
}
 
开发者ID:apache,项目名称:ignite,代码行数:8,代码来源:IgfsDeleteMessage.java

示例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.");
}
 
开发者ID:apache,项目名称:ignite,代码行数:37,代码来源:DataStreamProcessor.java

示例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);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:10,代码来源:CacheEventSerializer.java


注:本文中的org.apache.ignite.internal.util.typedef.internal.U.marshal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。