org.apache.hadoop.mapreduce.split.JobSplit#org.apache.ignite.IgniteException源码实例Demo

下面列出了org.apache.hadoop.mapreduce.split.JobSplit#org.apache.ignite.IgniteException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ignite   文件: GridAffinityProcessor.java
/** {@inheritDoc} */
@Override public int[] backupPartitions(ClusterNode n) {
    ctx.gateway().readLock();

    try {
        Set<Integer> parts = cache().assignment().backupPartitions(n.id());

        return U.toIntArray(parts);
    }
    catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
    finally {
        ctx.gateway().readUnlock();
    }
}
 
源代码2 项目: ignite   文件: GridAffinityProcessor.java
/** {@inheritDoc} */
@Override public Map<ClusterNode, Collection<K>> mapKeysToNodes(@Nullable Collection<? extends K> keys) {
    ctx.gateway().readLock();

    try {
        if (F.isEmpty(keys))
            return Collections.emptyMap();

        AffinityInfo affInfo = cache();

        return affinityMap(affInfo, keys);
    }
    catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
    finally {
        ctx.gateway().readUnlock();
    }
}
 
源代码3 项目: ignite   文件: IgniteCacheProxyImpl.java
/**
 * @param keys Keys.
 * @return Values map.
 */
public Map<K, V> getAll(Collection<? extends K> keys) {
    IgniteInternalCache<K, V> delegate = getDelegateSafe();

    try {
        if (isAsync()) {
            setFuture(delegate.getAllAsync(keys));

            return null;
        }
        else
            return delegate.getAll(keys);
    }
    catch (IgniteCheckedException | IgniteException e) {
        throw cacheException(e);
    }
}
 
源代码4 项目: ignite   文件: IgniteCacheProxyImpl.java
/** {@inheritDoc} */
@Override public boolean replace(K key, V val) {
    IgniteInternalCache<K, V> delegate = getDelegateSafe();

    try {
        if (isAsync()) {
            setFuture(delegate.replaceAsync(key, val));

            return false;
        }
        else
            return delegate.replace(key, val);
    }
    catch (IgniteCheckedException | IgniteException e) {
        throw cacheException(e);
    }
}
 
源代码5 项目: ignite   文件: StormStreamer.java
/**
 * Starts streamer.
 *
 * @throws IgniteException If failed.
 */
@SuppressWarnings("unchecked")
public void start() throws IgniteException {
    A.notNull(igniteConfigFile, "Ignite config file");
    A.notNull(cacheName, "Cache name");
    A.notNull(igniteTupleField, "Ignite tuple field");

    setIgnite(StreamerContext.getIgnite());

    final IgniteDataStreamer<K, V> dataStreamer = StreamerContext.getStreamer();
    dataStreamer.autoFlushFrequency(autoFlushFrequency);
    dataStreamer.allowOverwrite(allowOverwrite);

    setStreamer(dataStreamer);

    log = getIgnite().log();

    stopped = false;
}
 
源代码6 项目: ignite   文件: IgniteMessagingImpl.java
/** {@inheritDoc} */
@Override public IgniteFuture<UUID> remoteListenAsync(@Nullable Object topic,
    IgniteBiPredicate<UUID, ?> p) throws IgniteException {
    A.notNull(p, "p");

    guard();

    try {
        GridContinuousHandler hnd = new GridMessageListenHandler(topic, securityAwareBiPredicate(p));

        return new IgniteFutureImpl<>(ctx.continuous().startRoutine(hnd,
            false,
            1,
            0,
            false,
            prj.predicate()));
    }
    catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
    finally {
        unguard();
    }
}
 
/**
 * Sets binary config.
 *
 * @param igniteCfg Ignite config.
 * @param dotNetCfg .NET 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();
}
 
源代码8 项目: ignite   文件: CacheEntryProcessorExample.java
/**
 * Executes example.
 *
 * @param args Command line arguments, none required.
 * @throws IgniteException If example execution failed.
 */
public static void main(String[] args) throws IgniteException {
    try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
        System.out.println();
        System.out.println(">>> Entry processor example started.");

        // Auto-close cache at the end of the example.
        try (IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(CACHE_NAME)) {
            // Demonstrates usage of EntryProcessor.invoke(...) method.
            populateEntriesWithInvoke(cache);

            // Demonstrates usage of EntryProcessor.invokeAll(...) method.
            incrementEntriesWithInvokeAll(cache);
        }
        finally {
            // Distributed cache could be removed from cluster only by #destroyCache() call.
            ignite.destroyCache(CACHE_NAME);
        }
    }
}
 
源代码9 项目: ignite   文件: TxLog.java
/**
 * @param ctx Checkpoint context.
 * @throws IgniteCheckedException If failed.
 */
private void saveReuseListMetadata(Context ctx) throws IgniteCheckedException {
    Executor executor = ctx.executor();
    if (executor == null)
        reuseList.saveMetadata(IoStatisticsHolderNoOp.INSTANCE);
    else {
        executor.execute(() -> {
            try {
                reuseList.saveMetadata(IoStatisticsHolderNoOp.INSTANCE);
            }
            catch (IgniteCheckedException e) {
                throw new IgniteException(e);
            }
        });
    }
}
 
源代码10 项目: ignite   文件: SplitterUtils.java
/**
 * @param el Element.
 * @param paramsCnt Number of parameters.
 * @param paramIdxs Parameter indexes.
 */
private static void findParams(@Nullable GridSqlAst el, int paramsCnt, TreeSet<Integer> paramIdxs) {
    if (el == null)
        return;

    if (el instanceof GridSqlParameter) {
        // H2 Supports queries like "select ?5" but first 4 non-existing parameters are need to be set to any value.
        // Here we will set them to NULL.
        final int idx = ((GridSqlParameter)el).index();

        if (paramsCnt <= idx)
            throw new IgniteException("Invalid number of query parameters. " +
                "Cannot find " + idx + " parameter.");

        paramIdxs.add(idx);
    }
    else if (el instanceof GridSqlSubquery)
        findParamsQuery(((GridSqlSubquery)el).subquery(), paramsCnt, paramIdxs);
    else {
        for (int i = 0; i < el.size(); i++)
            findParams(el.child(i), paramsCnt, paramIdxs);
    }
}
 
源代码11 项目: ignite   文件: PlatformComputeBinarizableArgTask.java
/** {@inheritDoc} */
@Nullable @Override public Object execute() {
    BinaryObjectEx arg0 = ((BinaryObjectEx)arg);

    BinaryType meta = ignite.binary().type(arg0.typeId());

    if (meta == null)
        throw new IgniteException("Metadata doesn't exist.");

    if (meta.fieldNames() == null || !meta.fieldNames().contains("Field"))
        throw new IgniteException("Field metadata doesn't exist.");

    if (!F.eq("int", meta.fieldTypeName("Field")))
        throw new IgniteException("Invalid field type: " + meta.fieldTypeName("Field"));

    if (meta.affinityKeyFieldName() != null)
        throw new IgniteException("Unexpected affinity key: " + meta.affinityKeyFieldName());

    return arg0.field("field");
}
 
源代码12 项目: ignite   文件: GridAffinityProcessor.java
/** {@inheritDoc} */
@Override public int[] primaryPartitions(ClusterNode n) {
    ctx.gateway().readLock();

    try {
        Set<Integer> parts = cache().assignment().primaryPartitions(n.id());

        return U.toIntArray(parts);
    }
    catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
    finally {
        ctx.gateway().readUnlock();
    }
}
 
源代码13 项目: ignite   文件: HadoopIgfsInProc.java
/** {@inheritDoc} */
@Override public Boolean mkdirs(final IgfsPath path, final Map<String, String> props)
    throws IgniteCheckedException {
    try {
        IgfsUserContext.doAs(user, new IgniteOutClosure<Void>() {
            @Override public Void apply() {
                igfs.mkdirs(path, props);

                return null;
            }
        });

        return true;
    }
    catch (IgniteException e) {
        throw new IgniteCheckedException(e);
    }
    catch (IllegalStateException ignored) {
        throw new HadoopIgfsCommunicationException("Failed to findIgfsAndCreate directory because Grid is stopping: " +
            path);
    }
}
 
源代码14 项目: ignite   文件: DurableBackgroundTasksProcessor.java
/** {@inheritDoc} */
@Override public void onReadyForRead(ReadOnlyMetastorage metastorage) {
    synchronized (metaStorageMux) {
        if (durableBackgroundTasks.isEmpty()) {
            try {
                metastorage.iterate(
                    STORE_DURABLE_BACKGROUND_TASK_PREFIX,
                    (key, val) -> durableBackgroundTasks.put(key, (DurableBackgroundTask)val),
                    true
                );
            }
            catch (IgniteCheckedException e) {
                throw new IgniteException("Failed to iterate durable background tasks storage.", e);
            }
        }
    }
}
 
源代码15 项目: ignite   文件: IgniteClusterImpl.java
/**
 * Verifies all nodes in current cluster topology support BaselineTopology feature so compatibilityMode flag is
 * enabled to reset.
 *
 * @param discoCache
 */
private void verifyBaselineTopologySupport(DiscoCache discoCache) {
    if (discoCache.minimumServerNodeVersion().compareTo(MIN_BLT_SUPPORTING_VER) < 0) {
        SB sb = new SB("Cluster contains nodes that don't support BaselineTopology: [");

        for (ClusterNode cn : discoCache.serverNodes()) {
            if (cn.version().compareTo(MIN_BLT_SUPPORTING_VER) < 0)
                sb
                    .a("[")
                    .a(cn.consistentId())
                    .a(":")
                    .a(cn.version())
                    .a("], ");
        }

        sb.d(sb.length() - 2, sb.length());

        throw new IgniteException(sb.a("]").toString());
    }
}
 
源代码16 项目: ignite   文件: GridServiceProcessor.java
/**
 * Validates service configuration.
 *
 * @param c Service configuration.
 * @throws IgniteException If validation failed.
 */
private void validate(ServiceConfiguration c) throws IgniteException {
    IgniteConfiguration cfg = ctx.config();

    DeploymentMode depMode = cfg.getDeploymentMode();

    if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED))
        throw new IgniteException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode);

    ensure(c.getName() != null, "getName() != null", null);
    ensure(c.getTotalCount() >= 0, "getTotalCount() >= 0", c.getTotalCount());
    ensure(c.getMaxPerNodeCount() >= 0, "getMaxPerNodeCount() >= 0", c.getMaxPerNodeCount());
    ensure(c.getService() != null, "getService() != null", c.getService());
    ensure(c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0,
        "c.getTotalCount() > 0 || c.getMaxPerNodeCount() > 0", null);
}
 
源代码17 项目: ignite   文件: ComputeBroadcastExample.java
/**
 * Gather system info from all nodes and print it out.
 *
 * @param ignite Ignite instance.
 * @throws IgniteException if failed.
 */
private static void gatherSystemInfo(Ignite ignite) throws IgniteException {
    // Gather system info from all nodes.
    Collection<String> res = ignite.compute().broadcast(() -> {
        System.out.println();
        System.out.println("Executing task on node: " + ignite.cluster().localNode().id());

        return "Node ID: " + ignite.cluster().localNode().id() + "\n" +
            "OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " +
            System.getProperty("os.arch") + "\n" +
            "User: " + System.getProperty("user.name") + "\n" +
            "JRE: " + System.getProperty("java.runtime.name") + " " +
            System.getProperty("java.runtime.version");
    });

    // Print result.
    System.out.println();
    System.out.println("Nodes system information:");
    System.out.println();

    res.forEach(r -> {
        System.out.println(r);
        System.out.println();
    });
}
 
源代码18 项目: ignite   文件: IgniteClusterSnapshotSelfTest.java
/** @throws Exception If fails. */
@Test
public void testClusterSnapshotInMemoryFail() throws Exception {
    persistence = false;

    IgniteEx srv = startGrid(0);

    srv.cluster().state(ACTIVE);

    IgniteEx clnt = startClientGrid(1);

    IgniteFuture<?> fut = clnt.snapshot().createSnapshot(SNAPSHOT_NAME);

    assertThrowsAnyCause(log,
        fut::get,
        IgniteException.class,
        "Snapshots on an in-memory clusters are not allowed.");
}
 
/** */
@Ignore("https://issues.apache.org/jira/browse/IGNITE-10723")
@Test
public void testIncompatibleTmLookup() {
    final IgniteEx ignite = grid(0);

    final CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    cacheCfg.setName("Foo");
    cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    cacheCfg.setTransactionManagerLookupClassName(TestTmLookup2.class.getName());

    GridTestUtils.assertThrows(log, new Callable<Object>() {
        @Override public Object call() throws IgniteException {
            ignite.createCache(cacheCfg);

            return null;
        }
    }, IgniteException.class, null);
}
 
源代码20 项目: ignite   文件: AtomicDataStructureProxy.java
/**
 * Checks removed status after fail.
 *
 * @param cause Initial exception.
 * @return Ignite runtime exception that corresponds the original {@code cause}.
 */
protected IgniteException checkRemovedAfterFail(Exception cause) {
    assert cause != null : "The original cause must not be null.";

    needCheckNotRemoved();

    try {
        checkRemoved();
    }
    catch (Exception e) {
        // The original exception should be returned.
    }

    if (cause instanceof IgniteCheckedException)
        return U.convertException((IgniteCheckedException) cause);
    else if (cause instanceof EntryProcessorException)
        return new IgniteException(cause.getMessage(), cause);
    else {
        assert cause instanceof IgniteException;

        return (IgniteException)cause;
    }
}
 
源代码21 项目: ignite   文件: ClientHttpTask.java
/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int gridSize, String arg) {
    try {
        JsonNode json = JSON_MAPPER.readTree(arg);

        List<String> list = null;

        if (json.isArray()) {
            list = new ArrayList<>();

            for (JsonNode child : json)
                list.add(child.asText());
        }

        return delegate.split(gridSize, list);
    }
    catch (IOException e) {
        throw new IgniteException(e);
    }
}
 
/** {@inheritDoc} */
@Override public int partition(Object key) {
    Integer regionId;

    if (key instanceof RegionKey)
        regionId = ((RegionKey)key).regionId;
    else if (key instanceof BinaryObject) {
        BinaryObject bo = (BinaryObject)key;

        regionId = bo.field("regionId");
    }
    else
        throw new IgniteException("Unsupported key for region aware affinity");

    List<Integer> range = REGION_TO_PART_MAP.get(regionId);

    Integer cnt = range.get(1);

    return U.safeAbs(key.hashCode() % cnt) + range.get(0); // Assign partition in region's range.
}
 
源代码23 项目: ignite   文件: RdbmsBenchmark.java
/**
 * Set args to prepared upsert statement.
 *
 * @param stmt Statement.
 * @param newKey Key.
 * @param newVal Value.
 * @throws SQLException if failed.
 */
private static void setUpsertStatementArgs(PreparedStatement stmt, long newKey, long newVal)
    throws SQLException {
    switch (stmt.getConnection().getMetaData().getDatabaseProductName()) {
        case "H2":
            // No-op.
            break;

        case "Apache Ignite":
            // No-op.
            break;

        case "MySQL":
        case "PostgreSQL":
            stmt.setLong(3, newVal);

            break;

        default:
            throw new IgniteException("Unexpected database type [databaseProductName=" +
                stmt.getConnection().getMetaData().getDatabaseProductName() + ']');
    }
    stmt.setLong(1, newKey);
    stmt.setLong(2, newVal);
}
 
源代码24 项目: ignite   文件: GridH2Table.java
/**
 * Retrieves partitions size.
 *
 * @return Rows count.
 */
private long cacheSize(CachePeekMode... modes) {
    try {
        return cacheInfo.cacheContext().cache().localSize(modes);
    }
    catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
}
 
源代码25 项目: ignite   文件: VisorIgfsFormatTask.java
/** {@inheritDoc} */
@Override protected Void run(VisorIgfsFormatTaskArg arg) {
    try {
        ignite.fileSystem(arg.getIgfsName()).clear();
    }
    catch (IllegalArgumentException iae) {
        throw new IgniteException("Failed to format IGFS: " + arg.getIgfsName(), iae);
    }

    return null;
}
 
源代码26 项目: ignite   文件: GridCacheTxNodeFailureSelfTest.java
/** {@inheritDoc} */
@Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) {
    GridIoMessage ioMsg = (GridIoMessage)msg;

    if (!bannedClasses.contains(ioMsg.message().getClass()))
        super.sendMessage(node, msg, ackC);
}
 
源代码27 项目: ignite   文件: IgfsIgniteMock.java
/** {@inheritDoc} */
@Override public IgniteAtomicSequence atomicSequence(String name, AtomicConfiguration cfg, long initVal,
    boolean create) throws IgniteException {
    throwUnsupported();

    return null;
}
 
源代码28 项目: ignite   文件: VisorScanQueryCancelTask.java
/** {@inheritDoc} */
@Override protected Void run(@Nullable VisorScanQueryCancelTaskArg arg) throws IgniteException {
    new QueryMXBeanImpl(ignite.context())
        .cancelScan(arg.getOriginNodeId(), arg.getCacheName(), arg.getQueryId());

    return null;
}
 
源代码29 项目: ignite   文件: IgniteDynamicCacheConfigTest.java
/**
 * @throws Exception If failed.
 */
@Test
public void testDynamicCacheStartFromNotExistConfig() throws Exception {
    try {
        ignite(0).getOrCreateCache(load("config/cache.xml"));

        fail();
    }
    catch (IgniteException ignored) {
        // No-op.
    }
}
 
源代码30 项目: ignite   文件: GridCacheSetImpl.java
/** {@inheritDoc} */
@Override public <R> R affinityCall(IgniteCallable<R> job) {
    if (!collocated)
        throw new IgniteException("Failed to execute affinityCall() for non-collocated set: " + name() +
            ". This operation is supported only for collocated sets.");

    return compute.affinityCall(cache.name(), setKey, job);
}