Search in sources :

Example 31 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class GroupTrainer method train.

/**
 * {@inheritDoc}
 */
@Override
public final M train(T data) {
    UUID trainingUUID = UUID.randomUUID();
    LC locCtx = initialLocalContext(data, trainingUUID);
    GroupTrainingContext<K, V, LC> ctx = new GroupTrainingContext<>(locCtx, cache, ignite);
    ComputationsChain<LC, K, V, T, T> chain = (i, c) -> i;
    IgniteFunction<GroupTrainerCacheKey<K>, ResultAndUpdates<IN>> distributedInitializer = distributedInitializer(data);
    init(data, trainingUUID);
    M res = chain.thenDistributedForKeys(distributedInitializer, (t, lc) -> data.initialKeys(trainingUUID), reduceDistributedInitData()).thenLocally(this::locallyProcessInitData).thenWhile(this::shouldContinue, trainingLoopStep()).thenDistributedForEntries(this::extractContextForFinalResultCreation, finalResultsExtractor(), this::finalResultKeys, finalResultsReducer()).thenLocally(this::mapFinalResult).process(data, ctx);
    cleanup(locCtx);
    return res;
}
Also used : IgniteFunction(org.apache.ignite.ml.math.functions.IgniteFunction) IgniteSupplier(org.apache.ignite.ml.math.functions.IgniteSupplier) Model(org.apache.ignite.ml.Model) ComputationsChain(org.apache.ignite.ml.trainers.group.chain.ComputationsChain) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) IgniteCache(org.apache.ignite.IgniteCache) Serializable(java.io.Serializable) Trainer(org.apache.ignite.ml.trainers.Trainer) EntryAndContext(org.apache.ignite.ml.trainers.group.chain.EntryAndContext) List(java.util.List) Stream(java.util.stream.Stream) HasTrainingUUID(org.apache.ignite.ml.trainers.group.chain.HasTrainingUUID) UUID(java.util.UUID) HasTrainingUUID(org.apache.ignite.ml.trainers.group.chain.HasTrainingUUID)

Example 32 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class GridMBeanExoticNamesSelfTest method checkMBeanRegistration.

/**
 * Test MBean registration.
 */
private void checkMBeanRegistration(String grp, String name) throws Exception {
    // Node should start and stop with no errors.
    try (Ignite ignite = startGrid(0)) {
        MBeanServer srv = ignite.configuration().getMBeanServer();
        U.registerMBean(srv, ignite.name(), grp, name, new DummyMBeanImpl(), DummyMBean.class);
        ObjectName objName = U.makeMBeanName(ignite.name(), grp, name + '2');
        U.registerMBean(srv, objName, new DummyMBeanImpl(), DummyMBean.class);
    }
}
Also used : Ignite(org.apache.ignite.Ignite) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 33 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class LinuxNativeIoPluginProvider method start.

/**
 * {@inheritDoc}
 */
@Override
public void start(PluginContext ctx) {
    final Ignite ignite = ctx.grid();
    log = ignite.log();
    managedBuffers = setupDirect((IgniteEx) ignite);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite)

Example 34 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class IgniteCacheJoinPartitionedAndReplicatedTest method testJoin.

/**
 * @throws Exception If failed.
 */
public void testJoin() throws Exception {
    fail("https://issues.apache.org/jira/browse/IGNITE-5016");
    Ignite client = grid(2);
    IgniteCache<Object, Object> personCache = client.cache(PERSON_CACHE);
    IgniteCache<Object, Object> orgCache = client.cache(ORG_CACHE);
    IgniteCache<Object, Object> orgCacheRepl = client.cache(ORG_CACHE_REPLICATED);
    List<Integer> keys = primaryKeys(ignite(0).cache(PERSON_CACHE), 3, 200_000);
    orgCache.put(keys.get(0), new Organization(0, "org1"));
    orgCacheRepl.put(keys.get(0), new Organization(0, "org1"));
    personCache.put(keys.get(1), new Person(0, "p1"));
    personCache.put(keys.get(2), new Person(0, "p2"));
    checkQuery("select o.name, p._key, p.name " + "from \"person\".Person p join \"org\".Organization o " + "on (p.orgId = o.id)", orgCache, 2);
    checkQuery("select o.name, p._key, p.name " + "from \"org\".Organization o join \"person\".Person p " + "on (p.orgId = o.id)", orgCache, 2);
    checkQuery("select o.name, p._key, p.name " + "from \"person\".Person p join \"orgRepl\".Organization o " + "on (p.orgId = o.id)", orgCacheRepl, 2);
    checkQuery("select o.name, p._key, p.name " + "from \"orgRepl\".Organization o join \"person\".Person p " + "on (p.orgId = o.id)", orgCacheRepl, 2);
    checkQuery("select p.name from \"person\".Person p", ignite(0).cache(PERSON_CACHE), 2);
    checkQuery("select p.name from \"person\".Person p", ignite(1).cache(PERSON_CACHE), 2);
    for (int i = 0; i < 10; i++) checkQuery("select p.name from \"person\".Person p", personCache, 2);
    checkQuery("select o.name, p._key, p.name " + "from \"org\".Organization o left join \"person\".Person p " + "on (p.orgId = o.id)", orgCache, 2);
    checkQuery("select o.name, p._key, p.name " + "from \"person\".Person p left join \"orgRepl\".Organization o " + "on (p.orgId = o.id)", orgCacheRepl, 2);
    checkQuery("select o.name, p._key, p.name " + "from \"orgRepl\".Organization o left join \"person\".Person p " + "on (p.orgId = o.id)", orgCacheRepl, 2);
}
Also used : Ignite(org.apache.ignite.Ignite)

Example 35 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class IgniteCacheMultipleIndexedTypesTest method testMultipleIndexedTypes.

/**
 * @throws Exception If failed.
 */
public void testMultipleIndexedTypes() throws Exception {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    List<QueryEntity> qryEntities = new ArrayList<>();
    {
        QueryEntity qryEntity = new QueryEntity();
        qryEntity.setKeyType(Integer.class.getName());
        qryEntity.setValueType(Person.class.getName());
        LinkedHashMap<String, String> fields = new LinkedHashMap<>();
        fields.put("name", String.class.getName());
        qryEntity.setFields(fields);
        qryEntity.setIndexes(F.asList(new QueryIndex("name")));
        qryEntities.add(qryEntity);
    }
    {
        QueryEntity qryEntity = new QueryEntity();
        qryEntity.setKeyType(Integer.class.getName());
        qryEntity.setValueType(Organization.class.getName());
        LinkedHashMap<String, String> fields = new LinkedHashMap<>();
        fields.put("name", String.class.getName());
        qryEntity.setFields(fields);
        qryEntity.setIndexes(F.asList(new QueryIndex("name")));
        qryEntities.add(qryEntity);
    }
    ccfg.setQueryEntities(qryEntities);
    Ignite ignite = ignite(0);
    IgniteCache<Object, Object> cache = ignite.createCache(ccfg);
    checkCount(cache, Person.class, 0);
    cache.put(1, new Person("a"));
    checkCount(cache, Person.class, 1);
    cache.remove(1);
    checkCount(cache, Person.class, 0);
    cache.put(1, new Person("a"));
    checkCount(cache, Person.class, 1);
    cache.put(1, new Organization("a"));
    checkCount(cache, Person.class, 0);
    checkCount(cache, Organization.class, 1);
    cache.put(1, new Person("a"));
    checkCount(cache, Person.class, 1);
    checkCount(cache, Organization.class, 0);
    cache.put(2, new Person("a"));
    checkCount(cache, Person.class, 2);
    checkCount(cache, Organization.class, 0);
    cache.put(1, new Organization("a"));
    checkCount(cache, Person.class, 1);
    checkCount(cache, Organization.class, 1);
}
Also used : ArrayList(java.util.ArrayList) QueryIndex(org.apache.ignite.cache.QueryIndex) Ignite(org.apache.ignite.Ignite) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Ignite (org.apache.ignite.Ignite)2007 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)358 CountDownLatch (java.util.concurrent.CountDownLatch)238 IgniteCache (org.apache.ignite.IgniteCache)234 IgniteException (org.apache.ignite.IgniteException)216 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)215 Transaction (org.apache.ignite.transactions.Transaction)194 ArrayList (java.util.ArrayList)177 ClusterNode (org.apache.ignite.cluster.ClusterNode)152 UUID (java.util.UUID)137 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)135 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)128 CacheException (javax.cache.CacheException)112 Event (org.apache.ignite.events.Event)112 HashMap (java.util.HashMap)105 List (java.util.List)89 IgniteEx (org.apache.ignite.internal.IgniteEx)85 Map (java.util.Map)84 GridAbsPredicate (org.apache.ignite.internal.util.lang.GridAbsPredicate)81 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)78