/** * Create binary marshaller. * * @return Marshaller. */ public static GridBinaryMarshaller marshaller() { BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(new MarshallerContextImpl(null, null)); ctx.configure(marsh, new IgniteConfiguration()); return new GridBinaryMarshaller(ctx); }
/** Create new marshaller implementation. */ private GridBinaryMarshaller createImpl(BinaryConfiguration binCfg) { IgniteConfiguration igniteCfg = new IgniteConfiguration(); if (binCfg == null) { binCfg = new BinaryConfiguration(); binCfg.setCompactFooter(false); } igniteCfg.setBinaryConfiguration(binCfg); BinaryContext ctx = new BinaryContext(metaHnd, igniteCfg, new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(marshCtx); ctx.configure(marsh, igniteCfg); ctx.registerUserTypesSchema(); return new GridBinaryMarshaller(ctx); } }
/** * Create instance of {@link BinaryMarshaller} suitable for use * without starting a grid upon given {@link IgniteConfiguration}. * * @return Binary marshaller. * @throws IgniteCheckedException if failed. */ protected BinaryMarshaller createStandaloneBinaryMarshaller(IgniteConfiguration cfg) throws IgniteCheckedException { BinaryMarshaller marsh = new BinaryMarshaller(); BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), cfg, new NullLogger()); marsh.setContext(new MarshallerContextTestImpl()); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, cfg); return marsh; }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger()); marsh = new BinaryMarshaller(); IgniteConfiguration iCfg = new IgniteConfiguration(); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName()))); bCfg.setCompactFooter(compactFooter()); iCfg.setBinaryConfiguration(bCfg); marsh.setContext(new MarshallerContextTestImpl(null)); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg); }
/** * Create marshaller. * * @return Binary marshaller. * @throws Exception If failed. */ protected BinaryMarshaller createMarshaller() throws Exception { BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setCompactFooter(compactFooter()); bCfg.setTypeConfigurations(Arrays.asList( new BinaryTypeConfiguration(TestObject.class.getName()), new BinaryTypeConfiguration(TestOuterObject.class.getName()), new BinaryTypeConfiguration(TestInnerObject.class.getName()) )); IgniteConfiguration iCfg = new IgniteConfiguration(); iCfg.setBinaryConfiguration(bCfg); marsh.setContext(new MarshallerContextTestImpl(null)); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg); return marsh; }
/** * @throws Exception If failed. */ @Test public void testDeclaredBodyEnum() throws Exception { final MarshallerContextTestImpl ctx = new MarshallerContextTestImpl(); ctx.registerClassName((byte)0, 1, EnumObject.class.getName()); ctx.registerClassName((byte)0, 2, DeclaredBodyEnum.class.getName()); BinaryMarshaller marsh = binaryMarshaller(); marsh.setContext(ctx); EnumObject obj = new EnumObject(1L, "test 1", DeclaredBodyEnum.TWO); final byte[] marshal = marsh.marshal(obj); final Object restored = marsh.unmarshal(marshal, null); assertTrue(restored instanceof EnumObject); obj = (EnumObject)restored; assertEquals(1, obj.id); assertEquals(DeclaredBodyEnum.TWO.ordinal(), obj.type.ordinal()); assertEquals(DeclaredBodyEnum.TWO, obj.type); assertTrue(obj.type == DeclaredBodyEnum.TWO); }
/** * @return Binary marshaller. * @throws IgniteCheckedException if failed. */ private BinaryMarshaller binaryMarshaller() throws IgniteCheckedException { IgniteConfiguration iCfg = new IgniteConfiguration(); BinaryConfiguration bCfg = new BinaryConfiguration(); iCfg.setBinaryConfiguration(bCfg); BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(new MarshallerContextTestImpl(null)); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg); return marsh; }
/** * Create marshaller. * * @return Binary marshaller. * @throws Exception If failed. */ protected BinaryMarshaller createMarshaller() throws Exception { BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), log()); BinaryMarshaller marsh = new BinaryMarshaller(); BinaryConfiguration bCfg = new BinaryConfiguration(); IgniteConfiguration iCfg = new IgniteConfiguration(); iCfg.setBinaryConfiguration(bCfg); marsh.setContext(new MarshallerContextTestImpl(null)); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg); return marsh; }
/** {@inheritDoc} */ @Override protected Marshaller createMarshaller() throws IgniteCheckedException { BinaryMarshaller marsh = new BinaryMarshaller(); IgniteConfiguration iCfg = new IgniteConfiguration(); iCfg.setDiscoverySpi(new TcpDiscoverySpi() { @Override public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException { // No-op. } }); iCfg.setClientMode(false); GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg); kernCtx.add(new GridDiscoveryManager(kernCtx)); MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null); marshCtx.onMarshallerProcessorStarted(kernCtx, null); marsh.setContext(marshCtx); BinaryContext pCtx = new BinaryContext(BinaryNoopMetadataHandler.instance(), iCfg, new NullLogger()); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", pCtx, iCfg); return marsh; } }
marsh.setContext(new MarshallerContextTestImpl(null));
marsh.setContext(marshCtx);
public void testObjectExchange() throws Exception { BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(new MarshallerContextWithNoStorage());
/** * Create binary marshaller. * * @return Marshaller. */ @SuppressWarnings("deprecation") public static GridBinaryMarshaller marshaller() { BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(new MarshallerContextImpl(null, null)); ctx.configure(marsh, new IgniteConfiguration()); return new GridBinaryMarshaller(ctx); }
/** Create new marshaller implementation. */ private GridBinaryMarshaller createImpl(BinaryConfiguration binCfg) { IgniteConfiguration igniteCfg = new IgniteConfiguration(); if (binCfg == null) { binCfg = new BinaryConfiguration(); binCfg.setCompactFooter(false); } igniteCfg.setBinaryConfiguration(binCfg); BinaryContext ctx = new BinaryContext(metaHnd, igniteCfg, new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(marshCtx); ctx.configure(marsh, igniteCfg); ctx.registerUserTypesSchema(); return new GridBinaryMarshaller(ctx); } }