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