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.common.driver.catalog; 020 021import org.apache.reef.annotations.audience.Private; 022import org.apache.reef.driver.catalog.NodeDescriptor; 023import org.apache.reef.driver.catalog.RackDescriptor; 024 025import java.net.InetSocketAddress; 026 027@Private 028public class NodeDescriptorImpl implements NodeDescriptor { 029 030 private final RackDescriptorImpl rack; 031 032 private final String id; 033 034 private final InetSocketAddress address; 035 036 private final int ram; 037 038 /** 039 * @param id 040 * @param address 041 * @param rack 042 * @param ram the RAM available to the machine, in MegaBytes. 043 */ 044 NodeDescriptorImpl(final String id, final InetSocketAddress address, final RackDescriptorImpl rack, final int ram) { 045 this.id = id; 046 this.address = address; 047 this.rack = rack; 048 this.ram = ram; 049 this.rack.addNodeDescriptor(this); 050 } 051 052 @Override 053 public String toString() { 054 return "Node [" + this.address + "]: RACK " + this.rack.getName() + ", RAM " + ram; 055 } 056 057 @Override 058 public final String getId() { 059 return this.id; 060 } 061 062 063 @Override 064 public InetSocketAddress getInetSocketAddress() { 065 return this.address; 066 } 067 068 @Override 069 public RackDescriptor getRackDescriptor() { 070 return this.rack; 071 } 072 073 @Override 074 public String getName() { 075 return this.address.getHostName(); 076 } 077 078}