Java Code Examples for org.apache.ignite.configuration.BinaryConfiguration#setTypeConfigurations()
The following examples show how to use
org.apache.ignite.configuration.BinaryConfiguration#setTypeConfigurations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteCacheAbstractInsertSqlQuerySelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@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; }
Example 2
Source File: GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(cacheMode()); cacheCfg.setAtomicityMode(atomicityMode()); cacheCfg.setNearConfiguration(nearConfiguration()); cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode()); cfg.setCacheConfiguration(cacheCfg); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setTypeConfigurations(Arrays.asList( new BinaryTypeConfiguration(TestObject.class.getName()))); cfg.setBinaryConfiguration(bCfg); cfg.setMarshaller(new BinaryMarshaller()); return cfg; }
Example 3
Source File: GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(cacheMode()); cacheCfg.setAtomicityMode(atomicityMode()); cacheCfg.setNearConfiguration(nearConfiguration()); cacheCfg.setWriteSynchronizationMode(writeSynchronizationMode()); cfg.setCacheConfiguration(cacheCfg); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setTypeConfigurations(Arrays.asList( new BinaryTypeConfiguration(TestObject.class.getName()))); cfg.setBinaryConfiguration(bCfg); cfg.setMarshaller(new BinaryMarshaller()); return cfg; }
Example 4
Source File: BinaryEnumsSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (register) { BinaryConfiguration bCfg = new BinaryConfiguration(); BinaryTypeConfiguration enumCfg = new BinaryTypeConfiguration(EnumType.class.getName()); enumCfg.setEnum(true); if (igniteInstanceName.equals(WRONG_CONF_NODE_NAME)) enumCfg.setEnumValues(F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal(), EnumType.TWO.name(), EnumType.ONE.ordinal())); else enumCfg.setEnumValues(F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal(), EnumType.TWO.name(), EnumType.TWO.ordinal())); bCfg.setTypeConfigurations(Arrays.asList(enumCfg, new BinaryTypeConfiguration(EnumHolder.class.getName()))); cfg.setBinaryConfiguration(bCfg); } cfg.setMarshaller(new BinaryMarshaller()); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setName(CACHE_NAME); ccfg.setCacheMode(CacheMode.PARTITIONED); cfg.setCacheConfiguration(ccfg); return cfg; }
Example 5
Source File: GridBinaryWildcardsSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * */ protected BinaryMarshaller binaryMarshaller( BinaryNameMapper nameMapper, BinaryIdMapper mapper, BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs ) throws IgniteCheckedException { IgniteConfiguration iCfg = new IgniteConfiguration(); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setNameMapper(nameMapper); bCfg.setIdMapper(mapper); bCfg.setSerializer(serializer); bCfg.setTypeConfigurations(cfgs); iCfg.setBinaryConfiguration(bCfg); BinaryContext ctx = new BinaryContext(BinaryNoopMetadataHandler.instance(), iCfg, new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); marsh.setContext(new MarshallerContextTestImpl(null)); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg); return marsh; }
Example 6
Source File: IgnitePdsBinaryMetadataOnClusterRestartTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setConsistentId(gridName); if (customWorkSubDir != null) cfg.setWorkDirectory(Paths.get(U.defaultWorkDirectory(), customWorkSubDir).toString()); cfg.setDataStorageConfiguration( new DataStorageConfiguration() .setWalMode(WALMode.LOG_ONLY) .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setPersistenceEnabled(true) .setMaxSize(100L * 1024 * 1024)) ); BinaryConfiguration bCfg = new BinaryConfiguration(); BinaryTypeConfiguration binaryEnumCfg = new BinaryTypeConfiguration(EnumType.class.getName()); binaryEnumCfg.setEnum(true); binaryEnumCfg.setEnumValues(F.asMap(EnumType.ENUM_VAL_0.name(), EnumType.ENUM_VAL_0.ordinal(), EnumType.ENUM_VAL_1.name(), EnumType.ENUM_VAL_1.ordinal())); bCfg.setTypeConfigurations(Arrays.asList(binaryEnumCfg)); cfg.setBinaryConfiguration(bCfg); CacheKeyConfiguration dynamicMetaKeyCfg = new CacheKeyConfiguration(DYNAMIC_TYPE_NAME, DYNAMIC_INT_FIELD_NAME); cfg.setCacheKeyConfiguration(dynamicMetaKeyCfg); cfg.setCacheConfiguration(new CacheConfiguration() .setName(CACHE_NAME) .setAffinity(new RendezvousAffinityFunction()) .setCacheMode(CacheMode.REPLICATED)); return cfg; }
Example 7
Source File: GridCacheAffinityRoutingBinarySelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@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; }
Example 8
Source File: BinarySerializationQuerySelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setLocalHost("127.0.0.1"); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true)); cfg.setDiscoverySpi(discoSpi); cfg.setMarshaller(new BinaryMarshaller()); if (useReflectiveSerializer()) { BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration(EntityPlain.class.getName()); BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration(EntitySerializable.class.getName()); BinaryTypeConfiguration binTypCfg3 = new BinaryTypeConfiguration(EntityExternalizable.class.getName()); BinaryTypeConfiguration binTypCfg4 = new BinaryTypeConfiguration(EntityBinarylizable.class.getName()); BinaryTypeConfiguration binTypCfg5 = new BinaryTypeConfiguration(EntityWriteReadObject.class.getName()); binTypCfg1.setSerializer(new BinaryReflectiveSerializer()); binTypCfg2.setSerializer(new BinaryReflectiveSerializer()); binTypCfg3.setSerializer(new BinaryReflectiveSerializer()); binTypCfg4.setSerializer(new BinaryReflectiveSerializer()); binTypCfg5.setSerializer(new BinaryReflectiveSerializer()); List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>(); binTypCfgs.add(binTypCfg1); binTypCfgs.add(binTypCfg2); binTypCfgs.add(binTypCfg3); binTypCfgs.add(binTypCfg4); binTypCfgs.add(binTypCfg5); BinaryConfiguration binCfg = new BinaryConfiguration(); binCfg.setTypeConfigurations(binTypCfgs); cfg.setBinaryConfiguration(binCfg); } CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); cacheCfg.setCacheMode(CacheMode.PARTITIONED); cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC); List<QueryEntity> queryEntities = new ArrayList<>(); queryEntities.add(entityForClass(EntityPlain.class)); queryEntities.add(entityForClass(EntitySerializable.class)); queryEntities.add(entityForClass(EntityExternalizable.class)); queryEntities.add(entityForClass(EntityBinarylizable.class)); queryEntities.add(entityForClass(EntityWriteReadObject.class)); cacheCfg.setQueryEntities(queryEntities); cfg.setCacheConfiguration(cacheCfg); ignite = Ignition.start(cfg); cache = ignite.cache(DEFAULT_CACHE_NAME); }
Example 9
Source File: BinaryMarshallerSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** * @return Binary marshaller. */ protected BinaryMarshaller binaryMarshaller( BinaryNameMapper nameMapper, BinaryIdMapper mapper, BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs, Collection<String> excludedClasses ) throws IgniteCheckedException { IgniteConfiguration iCfg = new IgniteConfiguration(); BinaryConfiguration bCfg = new BinaryConfiguration(); bCfg.setNameMapper(nameMapper); bCfg.setIdMapper(mapper); bCfg.setSerializer(serializer); bCfg.setCompactFooter(compactFooter()); bCfg.setTypeConfigurations(cfgs); iCfg.setBinaryConfiguration(bCfg); iCfg.setClientMode(false); iCfg.setDiscoverySpi(new TcpDiscoverySpi() { @Override public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException { //No-op. } }); iCfg.setSystemViewExporterSpi(new JmxSystemViewExporterSpi()); BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger()); BinaryMarshaller marsh = new BinaryMarshaller(); MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null, excludedClasses); GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg); kernCtx.add(new GridSystemViewManager(kernCtx)); kernCtx.add(new GridDiscoveryManager(kernCtx)); marshCtx.onMarshallerProcessorStarted(kernCtx, null); marsh.setContext(marshCtx); IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg); return marsh; }
Example 10
Source File: BinaryFooterOffsetsAbstractSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@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); }
Example 11
Source File: BinaryArrayIdentityResolverSelfTest.java From ignite with Apache License 2.0 | 4 votes |
/** {@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; }
Example 12
Source File: GridCacheClientNodeBinaryObjectMetadataTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@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; }
Example 13
Source File: GridCacheBinaryObjectsAbstractSelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration cacheCfg = createCacheConfig(); cacheCfg.setCacheStoreFactory(singletonFactory(new TestStore())); CacheConfiguration binKeysCacheCfg = createCacheConfig(); binKeysCacheCfg.setCacheStoreFactory(singletonFactory(new MapCacheStoreStrategy.MapCacheStore())); binKeysCacheCfg.setStoreKeepBinary(true); binKeysCacheCfg.setName("BinKeysCache"); cfg.setCacheConfiguration(cacheCfg, binKeysCacheCfg); cfg.setMarshaller(new BinaryMarshaller()); List<BinaryTypeConfiguration> binTypes = new ArrayList<>(); binTypes.add(new BinaryTypeConfiguration() {{ setTypeName("ArrayHashedKey"); }}); BinaryConfiguration binCfg = new BinaryConfiguration(); binCfg.setTypeConfigurations(binTypes); cfg.setBinaryConfiguration(binCfg); CacheKeyConfiguration arrayHashCfg = new CacheKeyConfiguration("ArrayHashedKey", "fld1"); cfg.setCacheKeyConfiguration(arrayHashCfg); GridCacheBinaryObjectsAbstractSelfTest.cfg = cfg; return cfg; }
Example 14
Source File: CacheQueryBuildValueTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@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; }
Example 15
Source File: BinaryFieldsAbstractSelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** * 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; }
Example 16
Source File: BinaryConfigurationCustomSerializerSelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); cfg.setConnectorConfiguration(new ConnectorConfiguration()); cfg.setMarshaller(new BinaryMarshaller()); BinaryConfiguration binaryCfg = new BinaryConfiguration(); BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass"); btc.setIdMapper(BinaryContext.defaultIdMapper()); btc.setEnum(false); // Set custom serializer that is unknown for Optimized marshaller. btc.setSerializer(new MyBinarySerializer()); binaryCfg.setTypeConfigurations(Collections.singletonList(btc)); cfg.setBinaryConfiguration(binaryCfg); // Set custom consistent ID that unknown for Optimized marshaller. cfg.setConsistentId(new MyConsistentId("test")); cfg.setCacheConfiguration(new CacheConfiguration("TEST")); return cfg; }
Example 17
Source File: GridBinaryAffinityKeySelfTest.java From ignite with Apache License 2.0 | 3 votes |
/** {@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; }