This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.runtime.hdinsight.client.yarnrest;
020
021import org.codehaus.jackson.annotate.JsonProperty;
022import org.codehaus.jackson.map.ObjectMapper;
023
024import java.io.IOException;
025import java.io.StringWriter;
026
027/**
028 * Represents a resource to be localized. The key represents
029 * the file name or folder name  after localization, while the value
030 * provides the details of the localized resource.
031 * For detailed information, please refer to
032 * https://hadoop.apache.org/docs/r2.6.0/hadoop-yarn/hadoop-yarn-site/ResourceManagerRest.html
033 */
034public final class LocalResourcesEntry {
035
036  private static final String LOCAL_RESOURCES_ENTRY = "localResourcesEntry";
037  private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
038
039  private String key;
040  private LocalResource value;
041
042  public LocalResourcesEntry(final String key, final LocalResource value) {
043    this.key = key;
044    this.value = value;
045  }
046
047  @JsonProperty(Constants.KEY)
048  public String getKey() {
049    return this.key;
050  }
051
052  public LocalResourcesEntry setKey(final String key) {
053    this.key = key;
054    return this;
055  }
056
057  @JsonProperty(Constants.VALUE)
058  public LocalResource getValue() {
059    return this.value;
060  }
061
062  public LocalResourcesEntry setValue(final LocalResource value) {
063    this.value = value;
064    return this;
065  }
066
067  @Override
068  public String toString() {
069    final StringWriter writer = new StringWriter();
070    final String objectString;
071    try {
072      OBJECT_MAPPER.writeValue(writer, this);
073      objectString = writer.toString();
074    } catch (final IOException e) {
075      throw new RuntimeException("Exception while serializing LocalResourcesEntry: " + e);
076    }
077
078    return LOCAL_RESOURCES_ENTRY + objectString;
079  }
080}