Example usage for org.apache.hadoop.fs Path SEPARATOR

List of usage examples for org.apache.hadoop.fs Path SEPARATOR

Introduction

In this page you can find the example usage for org.apache.hadoop.fs Path SEPARATOR.

Prototype

String SEPARATOR

To view the source code for org.apache.hadoop.fs Path SEPARATOR.

Click Source Link

Document

The directory separator, a slash.

Usage

From source file:org.apache.ignite.internal.processors.hadoop.GridHadoopUtils.java

License:Apache License

/**
 * Gets staging area directory.//from  w  w w . j av  a 2 s. co  m
 *
 * @param conf Configuration.
 * @param usr User.
 * @return Staging area directory.
 */
public static Path stagingAreaDir(Configuration conf, String usr) {
    return new Path(conf.get(MRJobConfig.MR_AM_STAGING_DIR, MRJobConfig.DEFAULT_MR_AM_STAGING_DIR)
            + Path.SEPARATOR + usr + Path.SEPARATOR + STAGING_CONSTANT);
}

From source file:org.apache.ignite.internal.processors.hadoop.GridHadoopUtils.java

License:Apache License

/**
 * Gets job file./*w  w  w  .ja  v  a2s . c  o  m*/
 *
 * @param conf Configuration.
 * @param usr User.
 * @param jobId Job ID.
 * @return Job file.
 */
public static Path jobFile(Configuration conf, String usr, JobID jobId) {
    return new Path(stagingAreaDir(conf, usr), jobId.toString() + Path.SEPARATOR + MRJobConfig.JOB_CONF_FILE);
}

From source file:org.apache.ivory.entity.store.ConfigurationStore.java

License:Apache License

@Override
public void init() throws IvoryException {
    String listenerClassNames = StartupProperties.get().getProperty("configstore.listeners",
            "org.apache.ivory.entity.v0.EntityGraph");
    for (String listenerClassName : listenerClassNames.split(",")) {
        listenerClassName = listenerClassName.trim();
        if (listenerClassName.isEmpty())
            continue;
        ConfigurationChangeListener listener = ReflectionUtils.getInstanceByClassName(listenerClassName);
        registerListener(listener);/*from www .  j a  va2s  . c  om*/
    }

    try {
        for (EntityType type : EntityType.values()) {
            ConcurrentHashMap<String, Entity> entityMap = dictionary.get(type);
            FileStatus[] files = fs.globStatus(new Path(storePath, type.name() + Path.SEPARATOR + "*"));
            if (files != null) {
                for (FileStatus file : files) {
                    String fileName = file.getPath().getName();
                    String encodedEntityName = fileName.substring(0, fileName.length() - 4); // drop
                                                                                             // ".xml"
                    String entityName = URLDecoder.decode(encodedEntityName, UTF_8);
                    Entity entity = restore(type, entityName);
                    entityMap.put(entityName, entity);
                    onAdd(entity);
                }
            }
        }
    } catch (IOException e) {
        throw new IvoryException("Unable to restore configurations", e);
    }
}

From source file:org.apache.ivory.entity.store.ConfigurationStore.java

License:Apache License

/**
 * //from ww  w. ja  v a2  s .co m
 * @param type
 *            - Entity type that is to be stored into persistent storage
 * @param entity
 *            - entity to persist. JAXB Annotated entity will be marshalled
 *            to the persistent store. The convention used for storing the
 *            object:: PROP(config.store.uri)/{entitytype}/{entityname}.xml
 * @throws java.io.IOException
 *             If any error in accessing the storage
 * @throws IvoryException
 */
private void persist(EntityType type, Entity entity) throws IOException, IvoryException {
    OutputStream out = fs.create(
            new Path(storePath, type + Path.SEPARATOR + URLEncoder.encode(entity.getName(), UTF_8) + ".xml"));
    try {
        type.getMarshaller().marshal(entity, out);
        LOG.info("Persisted configuration " + type + "/" + entity.getName());
    } catch (JAXBException e) {
        LOG.error(e);
        throw new StoreAccessException("Unable to serialize the entity object " + type + "/" + entity.getName(),
                e);
    } finally {
        out.close();
    }
}

From source file:org.apache.ivory.entity.store.ConfigurationStore.java

License:Apache License

/**
 * Archive removed configuration in the persistent store
 * //from w  w w.j  av  a 2 s. co  m
 * @param type
 *            - Entity type to archive
 * @param name
 *            - name
 * @throws IOException
 *             If any error in accessing the storage
 */
private void archive(EntityType type, String name) throws IOException {
    Path archivePath = new Path(storePath, "archive" + Path.SEPARATOR + type);
    fs.mkdirs(archivePath);
    fs.rename(new Path(storePath, type + Path.SEPARATOR + URLEncoder.encode(name, UTF_8) + ".xml"),
            new Path(archivePath, URLEncoder.encode(name, UTF_8) + "." + System.currentTimeMillis()));
    LOG.info("Archived configuration " + type + "/" + name);
}

From source file:org.apache.ivory.entity.store.ConfigurationStore.java

License:Apache License

/**
 * //from  ww  w .j a v a2s. c  o m
 * @param type
 *            - Entity type to restore from persistent store
 * @param name
 *            - Name of the entity to restore.
 * @param <T>
 *            - Actual entity object type
 * @return - De-serialized entity object restored from persistent store
 * @throws IOException
 *             If any error in accessing the storage
 * @throws IvoryException
 */
@SuppressWarnings("unchecked")
private synchronized <T extends Entity> T restore(EntityType type, String name)
        throws IOException, IvoryException {

    InputStream in = fs
            .open(new Path(storePath, type + Path.SEPARATOR + URLEncoder.encode(name, UTF_8) + ".xml"));
    try {
        return (T) type.getUnmarshaller().unmarshal(in);
    } catch (JAXBException e) {
        throw new StoreAccessException("Unable to un-marshall xml definition for " + type + "/" + name, e);
    } finally {
        in.close();
        LOG.info("Restored configuration " + type + "/" + name);
    }
}

From source file:org.apache.mahout.feature.mrmr.MRMRDriver.java

License:Apache License

private String featureJobTempUri(Path basedir, int iteration) {
    return basedir.toUri() + Path.SEPARATOR + iteration + "_feature";
}

From source file:org.apache.mahout.feature.mrmr.MRMRDriver.java

License:Apache License

private String maxJobTempUri(Path basedir, int iteration) {
    return basedir.toUri() + Path.SEPARATOR + iteration + "_max";
}

From source file:org.apache.mahout.feature.mrmr.MRMRDriver.java

License:Apache License

private String cacheFileUri(Path basedir, int iteration) {
    return basedir.toUri() + Path.SEPARATOR + (iteration - 1) + "_max" + Path.SEPARATOR + "part-r-00000";
}

From source file:org.apache.mahout.text.PrefixAdditionFilter.java

License:Apache License

@Override
protected void process(FileStatus fst, Path current) throws IOException {
    FileSystem fs = getFs();//from   w  ww  .  j  a v  a2s  . co  m
    ChunkedWriter writer = getWriter();
    if (fst.isDir()) {
        String dirPath = getPrefix() + Path.SEPARATOR + current.getName() + Path.SEPARATOR
                + fst.getPath().getName();
        fs.listStatus(fst.getPath(),
                new PrefixAdditionFilter(getConf(), dirPath, getOptions(), writer, getCharset(), fs));
    } else {
        InputStream in = null;
        try {
            in = fs.open(fst.getPath());

            StringBuilder file = new StringBuilder();
            for (String aFit : new FileLineIterable(in, getCharset(), false)) {
                file.append(aFit).append('\n');
            }
            String name = current.getName().equals(fst.getPath().getName()) ? current.getName()
                    : current.getName() + Path.SEPARATOR + fst.getPath().getName();
            writer.write(getPrefix() + Path.SEPARATOR + name, file.toString());
        } finally {
            Closeables.close(in, false);
        }
    }
}