BinaryConfiguration c = new BinaryConfiguration(); c.setIdMapper(new BinaryBasicIdMapper(true)); c.setSerializer(new BinarySerializer() { @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException { c.setCompactFooter(compactFooter); c.setTypeConfigurations(Arrays.asList(btc));
/** * Create data transfer object for binary configuration. * * @param src Binary configuration. */ public VisorBinaryConfiguration(BinaryConfiguration src) { idMapper = compactClass(src.getIdMapper()); nameMapper = compactClass(src.getNameMapper()); serializer = compactClass(src.getSerializer()); compactFooter = src.isCompactFooter(); typeCfgs = VisorBinaryTypeConfiguration.list(src.getTypeConfigurations()); }
bCfg = new BinaryConfiguration(); bCfg.setCompactFooter(false); bCfg.setNameMapper(new BinaryBasicNameMapper(true)); bCfg.setIdMapper(new BinaryBasicIdMapper(true)); "note that binary name mapper is set to " + bCfg.getNameMapper() + " and binary ID mapper is set to " + bCfg.getIdMapper() + " (other nodes must have the same binary name and ID mapper types).")); BinaryNameMapper nameMapper = bCfg.getNameMapper(); bCfg.setNameMapper(new BinaryBasicNameMapper(true)); bCfg.getNameMapper() + " (other nodes must have the same binary name mapper type).")); BinaryIdMapper idMapper = bCfg.getIdMapper(); bCfg.setIdMapper(new BinaryBasicIdMapper(true)); bCfg.getIdMapper() + " (other nodes must have the same binary ID mapper type).")); if (bCfg.isCompactFooter()) throw new IgniteException("Unsupported " + BinaryMarshaller.class.getName() + " \"compactFooter\" flag: must be false when running Apache Ignite C++.");
return DFLT_MAPPER; BinaryIdMapper globalIdMapper = cfg.getIdMapper(); BinaryNameMapper globalNameMapper = cfg.getNameMapper(); Collection<BinaryTypeConfiguration> typeCfgs = cfg.getTypeConfigurations();
/** 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); } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); BinaryConfiguration binCfg = new BinaryConfiguration(); binCfg.setTypeConfigurations(Arrays.asList( new BinaryTypeConfiguration() {{ setTypeName(Key.class.getName()); }}, new BinaryTypeConfiguration() {{ setTypeName(Key2.class.getName()); }} )); cfg.setBinaryConfiguration(binCfg); cfg.setPeerClassLoadingEnabled(false); return cfg; }
bCfg = new BinaryConfiguration(); bCfg.setCompactFooter(false); bCfg = new BinaryConfiguration(); bCfg.setNameMapper(new BinaryBasicNameMapper(true));
/** {@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); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setNameMapper(new BinaryBasicNameMapper(false)); bCfg.setIdMapper(new BinaryBasicIdMapper(false)); bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName())); cfg.setBinaryConfiguration(bCfg); cfg.setMarshaller(new BinaryMarshaller()); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cfg.setCacheConfiguration(ccfg); GridDefaultBinaryMappersBinaryMetaDataSelfTest.cfg = cfg; return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(REPLICATED); CacheConfiguration cacheCfg2 = new CacheConfiguration("partitioned"); cacheCfg2.setCacheMode(PARTITIONED); cfg.setCacheConfiguration(cacheCfg, cacheCfg2); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setCompactFooter(compactFooter()); bCfg.setClassNames(Arrays.asList("org.apache.ignite.internal.binary.mutabletest.*")); cfg.setMarshaller(new BinaryMarshaller()); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); BinaryMarshaller marsh = new BinaryMarshaller(); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName())); BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(); typeCfg.setTypeName(TestObject1.class.getName()); CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(TestObject1.class.getName(), "val2"); cfg.setCacheKeyConfiguration(keyCfg); bCfg.setTypeConfigurations(Arrays.asList(typeCfg)); cfg.setBinaryConfiguration(bCfg); if (igniteInstanceName.equals(getTestIgniteInstanceName(gridCount() - 1))) cfg.setClientMode(true); cfg.setMarshaller(marsh); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true); return cfg; }
/** * @throws Exception If failed. */ @Test public void testNegativeNullEmptyConfigs() throws Exception { checkNegative(null, new BinaryConfiguration()); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception { final IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); final ServiceConfiguration scfg = new ServiceConfiguration(); if (igniteInstanceName.endsWith("0")) { scfg.setName("testService"); scfg.setService(srvc); scfg.setMaxPerNodeCount(1); scfg.setTotalCount(1); scfg.setNodeFilter(new NodeFilter()); final Map<String, String> attrs = new HashMap<>(); attrs.put("clusterGroup", "0"); cfg.setUserAttributes(attrs); cfg.setServiceConfiguration(scfg); } cfg.setMarshaller(null); final BinaryConfiguration binCfg = new BinaryConfiguration(); // Despite defaults explicitly set to lower case. binCfg.setIdMapper(new BinaryBasicIdMapper(true)); cfg.setBinaryConfiguration(binCfg); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); BinaryConfiguration bCfg = cfg.getBinaryConfiguration(); bCfg.setIdMapper(new BinaryBasicIdMapper(true)); bCfg.setNameMapper(new BinaryBasicNameMapper(true)); return cfg; } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setMarshaller(new BinaryMarshaller()); cfg.setCacheConfiguration( new CacheConfiguration(cacheName) .setCopyOnRead(true) ); BinaryConfiguration bcfg = new BinaryConfiguration() .setNameMapper(new BinaryBasicNameMapper(false)); cfg.setBinaryConfiguration(bcfg); return cfg; }
/** * @return Expected hash code. * @param fullName Full name of type. */ private int expectedHashCode(String fullName) { BinaryIdMapper idMapper = cfg.getBinaryConfiguration().getIdMapper(); BinaryNameMapper nameMapper = cfg.getBinaryConfiguration().getNameMapper(); if (idMapper == null) idMapper = BinaryContext.defaultIdMapper(); if (nameMapper == null) nameMapper = BinaryContext.defaultNameMapper(); return idMapper.typeId(nameMapper.typeName(fullName)); }
/** Serialization/deserialization. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { ClientConfiguration target = new ClientConfiguration() .setAddresses("127.0.0.1:10800", "127.0.0.1:10801") .setTimeout(123) .setBinaryConfiguration(new BinaryConfiguration() .setClassNames(Collections.singleton("Person")) ) .setSslMode(SslMode.REQUIRED) .setSslClientCertificateKeyStorePath("client.jks") .setSslClientCertificateKeyStoreType("JKS") .setSslClientCertificateKeyStorePassword("123456") .setSslTrustCertificateKeyStorePath("trust.jks") .setSslTrustCertificateKeyStoreType("JKS") .setSslTrustCertificateKeyStorePassword("123456") .setSslKeyAlgorithm("SunX509"); ByteArrayOutputStream outBytes = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(outBytes); out.writeObject(target); out.flush(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(outBytes.toByteArray())); Object desTarget = in.readObject(); assertTrue(Comparers.equal(target, desTarget)); }
w.writeBoolean(true); // binary config exists w.writeBoolean(true); // compact footer is set w.writeBoolean(bc.isCompactFooter()); w.writeBoolean(bc.getNameMapper() instanceof BinaryBasicNameMapper && ((BinaryBasicNameMapper)(bc.getNameMapper())).isSimpleName());
/** * @param clsName Class name. * @return Type name. */ private String expectedTypeName(String clsName) { BinaryNameMapper mapper = cfg.getBinaryConfiguration().getNameMapper(); if (mapper == null) mapper = BinaryContext.defaultNameMapper(); return mapper.typeName(clsName); }
/** * @return Default serializer. */ private BinarySerializer defaultSerializer() { BinaryConfiguration binCfg = igniteCfg.getBinaryConfiguration(); return binCfg != null ? binCfg.getSerializer() : null; }