Example usage for org.apache.hadoop.filecache DistributedCache getTimestamp

List of usage examples for org.apache.hadoop.filecache DistributedCache getTimestamp

Introduction

In this page you can find the example usage for org.apache.hadoop.filecache DistributedCache getTimestamp.

Prototype

@Deprecated
public static long getTimestamp(Configuration conf, URI cache) throws IOException 

Source Link

Document

Returns mtime of a given cache file on hdfs.

Usage

From source file:io.apigee.lembos.node.types.DistributedCacheWrap.java

License:Apache License

/**
 * Java wrapper for {@link DistributedCache#getTimestamp(Configuration, URI)}.
 *
 * @param ctx the JavaScript context/*from  ww w.j  a v a2s  .c o m*/
 * @param thisObj the 'this' object
 * @param args the function arguments
 * @param func the function being called
 *
 * @return the timestamp of the cache entry
 */
@JSStaticFunction
public static Object getTimestamp(final Context ctx, final Scriptable thisObj, final Object[] args,
        final Function func) {
    final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
    final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;

    if (args.length < 2) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
    } else if (!JavaScriptUtils.isDefined(arg0)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
    } else if (!JavaScriptUtils.isDefined(arg1)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
    } else if (!(arg0 instanceof ConfigurationWrap)) {
        throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
    }

    try {
        return DistributedCache.getTimestamp(((ConfigurationWrap) arg0).getConf(), URI.create(arg1.toString()));
    } catch (IOException e) {
        throw Utils.makeError(ctx, thisObj, e.getMessage());
    }
}