Search in sources :

Example 1 with INodeResolver

use of org.apache.asterix.external.api.INodeResolver in project asterixdb by apache.

the class LocalFSInputStreamFactory method configureFileSplits.

private void configureFileSplits(ICcApplicationContext appCtx, String[] splits) throws AsterixException {
    INodeResolver resolver = getNodeResolver();
    Map<InetAddress, Set<String>> ncMap = RuntimeUtils.getForcedNodeControllerMap(appCtx);
    Set<String> ncs = ncMap.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
    inputFileSplits = new UnmanagedFileSplit[splits.length];
    String node;
    String path;
    int count = 0;
    String trimmedValue;
    for (String splitPath : splits) {
        trimmedValue = splitPath.trim();
        if (!trimmedValue.contains("://")) {
            throw new AsterixException("Invalid path: " + splitPath + "\nUsage- path=\"Host://Absolute File Path\"");
        }
        node = resolver.resolveNode(appCtx, trimmedValue.split(":")[0], ncMap, ncs);
        path = trimmedValue.split("://")[1];
        inputFileSplits[count++] = new UnmanagedFileSplit(node, path);
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) AsterixException(org.apache.asterix.common.exceptions.AsterixException) INodeResolver(org.apache.asterix.external.api.INodeResolver) UnmanagedFileSplit(org.apache.hyracks.api.io.UnmanagedFileSplit) InetAddress(java.net.InetAddress) AlgebricksAbsolutePartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint)

Example 2 with INodeResolver

use of org.apache.asterix.external.api.INodeResolver in project asterixdb by apache.

the class LocalFSInputStreamFactory method initializeNodeResolver.

private static INodeResolver initializeNodeResolver() {
    INodeResolver nodeResolver = null;
    String configuredNodeResolverFactory = System.getProperty(ExternalDataConstants.NODE_RESOLVER_FACTORY_PROPERTY);
    if (configuredNodeResolverFactory != null) {
        try {
            nodeResolver = ((INodeResolverFactory) (Class.forName(configuredNodeResolverFactory).newInstance())).createNodeResolver();
        } catch (Exception e) {
            if (LOGGER.isLoggable(Level.WARNING)) {
                LOGGER.log(Level.WARNING, "Unable to create node resolver from the configured classname " + configuredNodeResolverFactory + "\n" + e.getMessage());
            }
            nodeResolver = DEFAULT_NODE_RESOLVER;
        }
    } else {
        nodeResolver = DEFAULT_NODE_RESOLVER;
    }
    return nodeResolver;
}
Also used : INodeResolver(org.apache.asterix.external.api.INodeResolver) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) AsterixException(org.apache.asterix.common.exceptions.AsterixException)

Aggregations

AsterixException (org.apache.asterix.common.exceptions.AsterixException)2 INodeResolver (org.apache.asterix.external.api.INodeResolver)2 InetAddress (java.net.InetAddress)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 AlgebricksAbsolutePartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 UnmanagedFileSplit (org.apache.hyracks.api.io.UnmanagedFileSplit)1