Search in sources :

Example 1 with IgfsProcessorAdapter

use of org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter in project ignite by apache.

the class IgfsTask method map.

/** {@inheritDoc} */
@Nullable
@Override
public final Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable IgfsTaskArgs<T> args) {
    assert ignite != null;
    assert args != null;
    IgniteFileSystem fs = ignite.fileSystem(args.igfsName());
    IgfsProcessorAdapter igfsProc = ((IgniteKernal) ignite).context().igfs();
    Map<ComputeJob, ClusterNode> splitMap = new HashMap<>();
    Map<UUID, ClusterNode> nodes = mapSubgrid(subgrid);
    for (IgfsPath path : args.paths()) {
        IgfsFile file = fs.info(path);
        if (file == null) {
            if (args.skipNonExistentFiles())
                continue;
            else
                throw new IgniteException("Failed to process IGFS file because it doesn't exist: " + path);
        }
        Collection<IgfsBlockLocation> aff = fs.affinity(path, 0, file.length(), args.maxRangeLength());
        long totalLen = 0;
        for (IgfsBlockLocation loc : aff) {
            ClusterNode node = null;
            for (UUID nodeId : loc.nodeIds()) {
                node = nodes.get(nodeId);
                if (node != null)
                    break;
            }
            if (node == null)
                throw new IgniteException("Failed to find any of block affinity nodes in subgrid [loc=" + loc + ", subgrid=" + subgrid + ']');
            IgfsJob job = createJob(path, new IgfsFileRange(file.path(), loc.start(), loc.length()), args);
            if (job != null) {
                ComputeJob jobImpl = igfsProc.createJob(job, fs.name(), file.path(), loc.start(), loc.length(), args.recordResolver());
                splitMap.put(jobImpl, node);
            }
            totalLen += loc.length();
        }
        assert totalLen == file.length();
    }
    return splitMap;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgfsProcessorAdapter(org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter) HashMap(java.util.HashMap) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) IgfsBlockLocation(org.apache.ignite.igfs.IgfsBlockLocation) IgfsPath(org.apache.ignite.igfs.IgfsPath) ComputeJob(org.apache.ignite.compute.ComputeJob) IgniteException(org.apache.ignite.IgniteException) UUID(java.util.UUID) IgfsFile(org.apache.ignite.igfs.IgfsFile) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with IgfsProcessorAdapter

use of org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter in project ignite by apache.

the class IgniteHadoopFileSystemClientSelfTest method switchHandlerErrorFlag.

/**
     * Set IGFS REST handler error flag to the given state.
     *
     * @param flag Flag state.
     * @throws Exception If failed.
     */
@SuppressWarnings("ConstantConditions")
private void switchHandlerErrorFlag(boolean flag) throws Exception {
    IgfsProcessorAdapter igfsProc = ((IgniteKernal) grid(0)).context().igfs();
    Map<String, IgfsContext> igfsMap = getField(igfsProc, "igfsCache");
    IgfsServerManager srvMgr = F.first(igfsMap.values()).server();
    Collection<IgfsServer> srvrs = getField(srvMgr, "srvrs");
    IgfsServerHandler igfsHnd = getField(F.first(srvrs), "hnd");
    Field field = igfsHnd.getClass().getDeclaredField("errWrite");
    field.setAccessible(true);
    field.set(null, flag);
}
Also used : Field(java.lang.reflect.Field) IgfsProcessorAdapter(org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter) IgfsServerManager(org.apache.ignite.internal.processors.igfs.IgfsServerManager) IgfsServerHandler(org.apache.ignite.internal.processors.igfs.IgfsServerHandler) IgfsContext(org.apache.ignite.internal.processors.igfs.IgfsContext) IgfsServer(org.apache.ignite.internal.processors.igfs.IgfsServer)

Example 3 with IgfsProcessorAdapter

use of org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter in project ignite by apache.

the class VisorNodeDataCollectorJob method igfs.

/**
     * Collect IGFSs.
     *
     * @param res Job result.
     */
protected void igfs(VisorNodeDataCollectorJobResult res) {
    try {
        IgfsProcessorAdapter igfsProc = ignite.context().igfs();
        for (IgniteFileSystem igfs : igfsProc.igfss()) {
            long start0 = U.currentTimeMillis();
            FileSystemConfiguration igfsCfg = igfs.configuration();
            if (proxyCache(igfsCfg.getDataCacheConfiguration().getName()) || proxyCache(igfsCfg.getMetaCacheConfiguration().getName()))
                continue;
            try {
                Collection<IpcServerEndpoint> endPoints = igfsProc.endpoints(igfs.name());
                if (endPoints != null) {
                    for (IpcServerEndpoint ep : endPoints) if (ep.isManagement())
                        res.getIgfsEndpoints().add(new VisorIgfsEndpoint(igfs.name(), ignite.name(), ep.getHost(), ep.getPort()));
                }
                res.getIgfss().add(new VisorIgfs(igfs));
            } finally {
                if (debug)
                    log(ignite.log(), "Collected IGFS: " + igfs.name(), getClass(), start0);
            }
        }
    } catch (Exception igfssEx) {
        res.setIgfssEx(igfssEx);
    }
}
Also used : IgfsProcessorAdapter(org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter) IpcServerEndpoint(org.apache.ignite.internal.util.ipc.IpcServerEndpoint) VisorIgfsEndpoint(org.apache.ignite.internal.visor.igfs.VisorIgfsEndpoint) VisorIgfs(org.apache.ignite.internal.visor.igfs.VisorIgfs) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration)

Aggregations

IgfsProcessorAdapter (org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter)3 IgniteFileSystem (org.apache.ignite.IgniteFileSystem)2 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 IgniteException (org.apache.ignite.IgniteException)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 ComputeJob (org.apache.ignite.compute.ComputeJob)1 FileSystemConfiguration (org.apache.ignite.configuration.FileSystemConfiguration)1 IgfsBlockLocation (org.apache.ignite.igfs.IgfsBlockLocation)1 IgfsFile (org.apache.ignite.igfs.IgfsFile)1 IgfsPath (org.apache.ignite.igfs.IgfsPath)1 IgfsContext (org.apache.ignite.internal.processors.igfs.IgfsContext)1 IgfsServer (org.apache.ignite.internal.processors.igfs.IgfsServer)1 IgfsServerHandler (org.apache.ignite.internal.processors.igfs.IgfsServerHandler)1 IgfsServerManager (org.apache.ignite.internal.processors.igfs.IgfsServerManager)1 IpcServerEndpoint (org.apache.ignite.internal.util.ipc.IpcServerEndpoint)1 VisorIgfs (org.apache.ignite.internal.visor.igfs.VisorIgfs)1 VisorIgfsEndpoint (org.apache.ignite.internal.visor.igfs.VisorIgfsEndpoint)1 Nullable (org.jetbrains.annotations.Nullable)1