Search in sources :

Example 26 with LinkedHashMap

use of java.util.LinkedHashMap in project hadoop by apache.

the class FSOperations method xAttrNamesToJSON.

/**
   * Converts xAttr names to a JSON object.
   *
   * @param names file xAttr names.
   *
   * @return The JSON representation of the xAttr names.
   * @throws IOException 
   */
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Map xAttrNamesToJSON(List<String> names) throws IOException {
    Map jsonMap = new LinkedHashMap();
    jsonMap.put(HttpFSFileSystem.XATTRNAMES_JSON, JSONArray.toJSONString(names));
    return jsonMap;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 27 with LinkedHashMap

use of java.util.LinkedHashMap in project hadoop by apache.

the class FSOperations method aclStatusToJSON.

/** Converts an <code>AclStatus</code> object into a JSON object.
   *
   * @param aclStatus AclStatus object
   *
   * @return The JSON representation of the ACLs for the file
   */
@SuppressWarnings({ "unchecked" })
private static Map<String, Object> aclStatusToJSON(AclStatus aclStatus) {
    Map<String, Object> json = new LinkedHashMap<String, Object>();
    Map<String, Object> inner = new LinkedHashMap<String, Object>();
    JSONArray entriesArray = new JSONArray();
    inner.put(HttpFSFileSystem.OWNER_JSON, aclStatus.getOwner());
    inner.put(HttpFSFileSystem.GROUP_JSON, aclStatus.getGroup());
    inner.put(HttpFSFileSystem.ACL_STICKY_BIT_JSON, aclStatus.isStickyBit());
    for (AclEntry e : aclStatus.getEntries()) {
        entriesArray.add(e.toString());
    }
    inner.put(HttpFSFileSystem.ACL_ENTRIES_JSON, entriesArray);
    json.put(HttpFSFileSystem.ACL_STATUS_JSON, inner);
    return json;
}
Also used : JSONArray(org.json.simple.JSONArray) AclEntry(org.apache.hadoop.fs.permission.AclEntry) JSONObject(org.json.simple.JSONObject) LinkedHashMap(java.util.LinkedHashMap)

Example 28 with LinkedHashMap

use of java.util.LinkedHashMap in project hadoop by apache.

the class FSOperations method toJson.

/**
   * @param fileStatuses list of FileStatus objects
   * @return JSON map suitable for wire transport
   */
@SuppressWarnings({ "unchecked" })
private static Map<String, Object> toJson(FileStatus[] fileStatuses) {
    Map<String, Object> json = new LinkedHashMap<>();
    Map<String, Object> inner = new LinkedHashMap<>();
    JSONArray statuses = new JSONArray();
    for (FileStatus f : fileStatuses) {
        statuses.add(toJsonInner(f, false));
    }
    inner.put(HttpFSFileSystem.FILE_STATUS_JSON, statuses);
    json.put(HttpFSFileSystem.FILE_STATUSES_JSON, inner);
    return json;
}
Also used : FileStatus(org.apache.hadoop.fs.FileStatus) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) LinkedHashMap(java.util.LinkedHashMap)

Example 29 with LinkedHashMap

use of java.util.LinkedHashMap in project hadoop by apache.

the class FSOperations method fileChecksumToJSON.

/**
   * Converts a <code>FileChecksum</code> object into a JSON array
   * object.
   *
   * @param checksum file checksum.
   *
   * @return The JSON representation of the file checksum.
   */
@SuppressWarnings({ "unchecked" })
private static Map fileChecksumToJSON(FileChecksum checksum) {
    Map json = new LinkedHashMap();
    json.put(HttpFSFileSystem.CHECKSUM_ALGORITHM_JSON, checksum.getAlgorithmName());
    json.put(HttpFSFileSystem.CHECKSUM_BYTES_JSON, org.apache.hadoop.util.StringUtils.byteToHexString(checksum.getBytes()));
    json.put(HttpFSFileSystem.CHECKSUM_LENGTH_JSON, checksum.getLength());
    Map response = new LinkedHashMap();
    response.put(HttpFSFileSystem.FILE_CHECKSUM_JSON, json);
    return response;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 30 with LinkedHashMap

use of java.util.LinkedHashMap in project hadoop by apache.

the class RumenToSLSConverter method createSLSTasks.

@SuppressWarnings("unchecked")
private static List createSLSTasks(String taskType, List rumenTasks, long offset) {
    int priority = taskType.equals("reduce") ? 10 : 20;
    List array = new ArrayList();
    for (Object e : rumenTasks) {
        Map rumenTask = (Map) e;
        for (Object ee : (List) rumenTask.get("attempts")) {
            Map rumenAttempt = (Map) ee;
            long taskStart = (Long) rumenAttempt.get("startTime");
            long taskFinish = (Long) rumenAttempt.get("finishTime");
            String hostname = (String) rumenAttempt.get("hostName");
            taskStart = taskStart - baseline + offset;
            taskFinish = taskFinish - baseline + offset;
            Map task = new LinkedHashMap();
            task.put("container.host", hostname);
            task.put("container.start.ms", taskStart);
            task.put("container.end.ms", taskFinish);
            task.put("container.priority", priority);
            task.put("container.type", taskType);
            array.add(task);
            String[] rackHost = SLSUtils.getRackHostName(hostname);
            if (rackNodeMap.containsKey(rackHost[0])) {
                rackNodeMap.get(rackHost[0]).add(rackHost[1]);
            } else {
                Set<String> hosts = new TreeSet<String>();
                hosts.add(rackHost[1]);
                rackNodeMap.put(rackHost[0], hosts);
            }
        }
    }
    return array;
}
Also used : TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1944 ArrayList (java.util.ArrayList)575 Map (java.util.Map)561 HashMap (java.util.HashMap)373 Test (org.junit.Test)275 List (java.util.List)255 IOException (java.io.IOException)122 HashSet (java.util.HashSet)91 Set (java.util.Set)79 File (java.io.File)76 LinkedHashSet (java.util.LinkedHashSet)68 TreeMap (java.util.TreeMap)68 Node (org.apache.hadoop.hive.ql.lib.Node)59 NodeProcessor (org.apache.hadoop.hive.ql.lib.NodeProcessor)58 Rule (org.apache.hadoop.hive.ql.lib.Rule)58 Date (java.util.Date)57 GraphWalker (org.apache.hadoop.hive.ql.lib.GraphWalker)56 Dispatcher (org.apache.hadoop.hive.ql.lib.Dispatcher)55 Iterator (java.util.Iterator)54 DefaultRuleDispatcher (org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher)54