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);
}
}
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;
}
Aggregations