Search in sources :

Example 31 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class GridCacheMvccSelfTest method testMarshalUnmarshalCandidate.

/**
 * @throws Exception If failed.
 */
public void testMarshalUnmarshalCandidate() throws Exception {
    GridCacheAdapter<String, String> cache = grid.internalCache(DEFAULT_CACHE_NAME);
    GridCacheTestEntryEx parent = new GridCacheTestEntryEx(cache.context(), "1");
    GridCacheMvccCandidate cand = new GridCacheMvccCandidate(parent, UUID.randomUUID(), UUID.randomUUID(), version(1), 123, version(2), /*local*/
    false, /*reentry*/
    false, true, false, false, false, null, false);
    Marshaller marshaller = getTestResources().getMarshaller();
    GridCacheMvccCandidate unmarshalled = marshaller.unmarshal(marshaller.marshal(cand), null);
    info(unmarshalled.toString());
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller)

Example 32 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class GridCacheMessage method unmarshalCollection.

/**
 * @param byteCol Collection to unmarshal.
 * @param ctx Context.
 * @param ldr Loader.
 * @return Unmarshalled collection.
 * @throws IgniteCheckedException If failed.
 */
@Nullable
protected <T> List<T> unmarshalCollection(@Nullable Collection<byte[]> byteCol, GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    assert ldr != null;
    assert ctx != null;
    if (byteCol == null)
        return null;
    List<T> col = new ArrayList<>(byteCol.size());
    Marshaller marsh = ctx.marshaller();
    for (byte[] bytes : byteCol) col.add(bytes == null ? null : U.<T>unmarshal(marsh, bytes, U.resolveClassLoader(ldr, ctx.gridConfig())));
    return col;
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller) ArrayList(java.util.ArrayList) Nullable(org.jetbrains.annotations.Nullable)

Example 33 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class GridCacheMessage method unmarshalInvokeArguments.

/**
 * @param byteCol Collection to unmarshal.
 * @param ctx Context.
 * @param ldr Loader.
 * @return Unmarshalled collection.
 * @throws IgniteCheckedException If failed.
 */
@Nullable
protected final Object[] unmarshalInvokeArguments(@Nullable byte[][] byteCol, GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    assert ldr != null;
    assert ctx != null;
    if (byteCol == null)
        return null;
    Object[] args = new Object[byteCol.length];
    Marshaller marsh = ctx.marshaller();
    for (int i = 0; i < byteCol.length; i++) args[i] = byteCol[i] == null ? null : U.unmarshal(marsh, byteCol[i], U.resolveClassLoader(ldr, ctx.gridConfig()));
    return args;
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller) Nullable(org.jetbrains.annotations.Nullable)

Example 34 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class GridCacheQueryRequest method finishUnmarshal.

/**
 * {@inheritDoc}
 */
@Override
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
    super.finishUnmarshal(ctx, ldr);
    Marshaller mrsh = ctx.marshaller();
    if (keyValFilterBytes != null && keyValFilter == null)
        keyValFilter = U.unmarshal(mrsh, keyValFilterBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
    if (rdcBytes != null && rdc == null)
        rdc = U.unmarshal(mrsh, rdcBytes, ldr);
    if (transBytes != null && trans == null)
        trans = U.unmarshal(mrsh, transBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
    if (argsBytes != null && args == null)
        args = U.unmarshal(mrsh, argsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller)

Example 35 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class GridCacheQueryRequest method beforeLocalExecution.

/**
 * @param ctx Context.
 * @throws IgniteCheckedException In case of error.
 */
void beforeLocalExecution(GridCacheContext ctx) throws IgniteCheckedException {
    Marshaller marsh = ctx.marshaller();
    rdc = rdc != null ? U.<IgniteReducer<Object, Object>>unmarshal(marsh, U.marshal(marsh, rdc), U.resolveClassLoader(ctx.gridConfig())) : null;
    trans = trans != null ? U.<IgniteClosure<Object, Object>>unmarshal(marsh, U.marshal(marsh, trans), U.resolveClassLoader(ctx.gridConfig())) : null;
}
Also used : IgniteReducer(org.apache.ignite.lang.IgniteReducer) Marshaller(org.apache.ignite.marshaller.Marshaller) IgniteClosure(org.apache.ignite.lang.IgniteClosure)

Aggregations

Marshaller (org.apache.ignite.marshaller.Marshaller)46 Externalizable (java.io.Externalizable)8 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 HttpURLConnection (java.net.HttpURLConnection)5 URL (java.net.URL)5 URLConnection (java.net.URLConnection)5 ArrayList (java.util.ArrayList)5 HttpSession (javax.servlet.http.HttpSession)5 IgniteException (org.apache.ignite.IgniteException)5 JdkMarshaller (org.apache.ignite.marshaller.jdk.JdkMarshaller)5 Ignite (org.apache.ignite.Ignite)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Server (org.eclipse.jetty.server.Server)4 File (java.io.File)2 OutputStream (java.io.OutputStream)2 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)2 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)2 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)2