/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMarshaller(new BinaryMarshaller()); BinaryConfiguration binCfg = new BinaryConfiguration(); BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration(); BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration(); binTypCfg1.setTypeName(InnerClass.class.getName()); binTypCfg2.setTypeName(InnerClassBinarylizable.class.getName()); List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>(); binTypCfgs.add(binTypCfg1); binTypCfgs.add(binTypCfg2); binCfg.setTypeConfigurations(binTypCfgs); cfg.setBinaryConfiguration(binCfg); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(); typeCfg.setTypeName(AffinityTestKey.class.getName()); CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(AffinityTestKey.class.getName(), "affKey"); cfg.setCacheKeyConfiguration(keyCfg); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setTypeConfigurations(Collections.singleton(typeCfg)); cfg.setBinaryConfiguration(bCfg); cfg.setMarshaller(new BinaryMarshaller()); return cfg; } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMarshaller(null); CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); QueryEntity entity = new QueryEntity(); entity.setKeyType(Integer.class.getName()); entity.setValueType(TestBuilderValue.class.getName()); ArrayList<QueryIndex> idxs = new ArrayList<>(); QueryIndex idx = new QueryIndex("iVal"); idxs.add(idx); LinkedHashMap<String, String> fields = new LinkedHashMap<>(); fields.put("iVal", Integer.class.getName()); entity.setFields(fields); entity.setIndexes(idxs); ccfg.setQueryEntities(Collections.singleton(entity)); cfg.setCacheConfiguration(ccfg); BinaryConfiguration binaryCfg = new BinaryConfiguration(); BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(); typeCfg.setTypeName(TestBuilderValue.class.getName()); binaryCfg.setTypeConfigurations(Collections.singletonList(typeCfg)); cfg.setBinaryConfiguration(binaryCfg); 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; }
/** * * @param nameMapper Name mapper. * @param mapper Mapper. * @throws IgniteCheckedException If failed. */ private void checkOverrideNameMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException { BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(); typeCfg.setTypeName(CLASS2_FULL_NAME); typeCfg.setNameMapper(new BinaryNameMapper() { @Override public String typeName(String clsName) { return "type2"; } @Override public String fieldName(String fieldName) { return "field2"; } }); BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList( new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), typeCfg)); BinaryContext ctx = binaryContext(marsh); ConcurrentMap<Integer, BinaryInternalMapper> types = U.field(ctx, "typeId2Mapper"); assertEquals(3, types.size()); assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper))); assertTrue(types.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper))); assertTrue(types.containsKey("type2".hashCode())); Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers"); assertEquals("type2", typeMappers.get(CLASS2_FULL_NAME).nameMapper().typeName(CLASS2_FULL_NAME)); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(); typeCfg.setTypeName(TestObject.class.getName()); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setTypeConfigurations(Collections.singleton(typeCfg)); cfg.setBinaryConfiguration(bCfg); CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(TestObject.class.getName(), "affKey"); CacheKeyConfiguration keyCfg2 = new CacheKeyConfiguration("TestObject2", "affKey"); cfg.setCacheKeyConfiguration(keyCfg, keyCfg2); cfg.setMarshaller(new BinaryMarshaller()); if (!igniteInstanceName.equals(getTestIgniteInstanceName(GRID_CNT))) { CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(PARTITIONED); cfg.setCacheConfiguration(cacheCfg); } return cfg; }
/** * * @param nameMapper Name mapper. * @param mapper Mapper. * @throws IgniteCheckedException If failed. */ private void checkOverrideIdMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException { BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(); typeCfg.setTypeName(CLASS2_FULL_NAME); typeCfg.setIdMapper(new BinaryIdMapper() { @Override public int typeId(String clsName) { return 100; } @Override public int fieldId(int typeId, String fieldName) { return 0; } }); BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList( new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), typeCfg)); BinaryContext ctx = binaryContext(marsh); Map<Integer, Class> typeIds = U.field(ctx, "userTypes"); assertEquals(3, typeIds.size()); assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper))); assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper))); assertTrue(typeIds.containsKey(100)); Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers"); assertEquals(100, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME)); }
btcfg1.setTypeName("org.apache.ignite.tests.p2p.CacheDeploymentTestValue"); btcfg2.setTypeName("org.apache.ignite.internal.processors.cache.binary." + "GridCacheBinaryObjectUserClassloaderSelfTest$TestValue1");
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration(); customTypeCfg.setTypeName(CustomIdMapper.class.getName()); customTypeCfg.setIdMapper(new BinaryIdMapper() { @Override public int typeId(String clsName) { return ~BinaryContext.defaultIdMapper().typeId(clsName); } @Override public int fieldId(int typeId, String fieldName) { return typeId + ~BinaryContext.defaultIdMapper().fieldId(typeId, fieldName); } }); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setCompactFooter(compactFooter()); bCfg.setTypeConfigurations(Arrays.asList( new BinaryTypeConfiguration(Key.class.getName()), new BinaryTypeConfiguration(Value.class.getName()), new BinaryTypeConfiguration("org.gridgain.grid.internal.util.binary.mutabletest.*"), customTypeCfg)); bCfg.setIdMapper(new BinaryBasicIdMapper(false)); bCfg.setNameMapper(new BinaryBasicNameMapper(false)); cfg.setBinaryConfiguration(bCfg); cfg.setMarshaller(new BinaryMarshaller()); this.cfg = cfg; return cfg; }