Search in sources :

Example 16 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class IgniteServiceProxyTimeoutInitializedTest method getConfiguration.

/** {@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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) HashMap(java.util.HashMap) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper)

Example 17 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class BinarySerializationQuerySelfTest method beforeTest.

/** {@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);
}
Also used : BinaryReflectiveSerializer(org.apache.ignite.binary.BinaryReflectiveSerializer) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 18 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class IgniteCacheAbstractInsertSqlQuerySelfTest method getConfiguration.

/** {@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);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(disco);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 19 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class PlatformDotNetConfigurationClosure method setBinaryConfiguration.

/**
     * Sets binary config.
     *
     * @param igniteCfg Ignite config.
     * @param dotNetCfg Dotnet config.
     */
private void setBinaryConfiguration(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx dotNetCfg) {
    // Check marshaller.
    Marshaller marsh = igniteCfg.getMarshaller();
    if (marsh == null) {
        igniteCfg.setMarshaller(new BinaryMarshaller());
        dotNetCfg.warnings(Collections.singleton("Marshaller is automatically set to " + BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
    } else if (!(marsh instanceof BinaryMarshaller))
        throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() + " can be used when running Apache Ignite.NET): " + marsh.getClass().getName());
    BinaryConfiguration bCfg = igniteCfg.getBinaryConfiguration();
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridBinaryMarshaller(org.apache.ignite.internal.binary.GridBinaryMarshaller) IgniteException(org.apache.ignite.IgniteException)

Example 20 with BinaryConfiguration

use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.

the class PlatformCppConfigurationClosure method apply0.

/** {@inheritDoc} */
@SuppressWarnings("deprecation")
@Override
protected void apply0(IgniteConfiguration igniteCfg) {
    // 3. Validate and copy Interop configuration setting environment pointer along the way.
    PlatformConfiguration interopCfg = igniteCfg.getPlatformConfiguration();
    if (interopCfg != null && !(interopCfg instanceof PlatformCppConfiguration))
        throw new IgniteException("Illegal interop configuration (must be of type " + PlatformCppConfiguration.class.getName() + "): " + interopCfg.getClass().getName());
    PlatformCppConfiguration cppCfg = interopCfg != null ? (PlatformCppConfiguration) interopCfg : null;
    if (cppCfg == null)
        cppCfg = new PlatformCppConfiguration();
    PlatformMemoryManagerImpl memMgr = new PlatformMemoryManagerImpl(gate, 1024);
    PlatformCppConfigurationEx cppCfg0 = new PlatformCppConfigurationEx(cppCfg, gate, memMgr);
    igniteCfg.setPlatformConfiguration(cppCfg0);
    // Check marshaller
    Marshaller marsh = igniteCfg.getMarshaller();
    if (marsh == null) {
        igniteCfg.setMarshaller(new BinaryMarshaller());
        cppCfg0.warnings(Collections.singleton("Marshaller is automatically set to " + BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
    } else if (!(marsh instanceof BinaryMarshaller))
        throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() + " can be used when running Apache Ignite C++): " + marsh.getClass().getName());
    BinaryConfiguration bCfg = igniteCfg.getBinaryConfiguration();
    if (bCfg == null) {
        bCfg = new BinaryConfiguration();
        bCfg.setCompactFooter(false);
        bCfg.setNameMapper(new BinaryBasicNameMapper(true));
        bCfg.setIdMapper(new BinaryBasicIdMapper(true));
        igniteCfg.setBinaryConfiguration(bCfg);
        cppCfg0.warnings(Collections.singleton("Binary configuration is automatically initiated, " + "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)."));
    } else {
        BinaryNameMapper nameMapper = bCfg.getNameMapper();
        if (nameMapper == null) {
            bCfg.setNameMapper(new BinaryBasicNameMapper(true));
            cppCfg0.warnings(Collections.singleton("Binary name mapper is automatically set to " + bCfg.getNameMapper() + " (other nodes must have the same binary name mapper type)."));
        }
        BinaryIdMapper idMapper = bCfg.getIdMapper();
        if (idMapper == null) {
            bCfg.setIdMapper(new BinaryBasicIdMapper(true));
            cppCfg0.warnings(Collections.singleton("Binary ID mapper is automatically set to " + 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++.");
    // Set Ignite home so that marshaller context works.
    String ggHome = igniteCfg.getIgniteHome();
    if (ggHome != null)
        U.setIgniteHome(ggHome);
}
Also used : PlatformConfiguration(org.apache.ignite.configuration.PlatformConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryBasicIdMapper(org.apache.ignite.binary.BinaryBasicIdMapper) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) PlatformCppConfiguration(org.apache.ignite.platform.cpp.PlatformCppConfiguration) IgniteException(org.apache.ignite.IgniteException) BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryNameMapper(org.apache.ignite.binary.BinaryNameMapper) PlatformMemoryManagerImpl(org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl)

Aggregations

BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)38 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)29 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)18 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)12 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)12 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)11 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)10 BinaryBasicIdMapper (org.apache.ignite.binary.BinaryBasicIdMapper)9 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)6 NullLogger (org.apache.ignite.logger.NullLogger)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)4 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)4 LinkedHashMap (java.util.LinkedHashMap)3 IgniteException (org.apache.ignite.IgniteException)3 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)3 BinaryIdMapper (org.apache.ignite.binary.BinaryIdMapper)2 BinaryReader (org.apache.ignite.binary.BinaryReader)2 BinarySerializer (org.apache.ignite.binary.BinarySerializer)2