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.wake.remote; 020 021import org.apache.reef.tang.annotations.Name; 022import org.apache.reef.tang.annotations.NamedParameter; 023import org.apache.reef.wake.EStage; 024import org.apache.reef.wake.EventHandler; 025import org.apache.reef.wake.WakeParameters; 026import org.apache.reef.wake.remote.impl.DefaultTransportEStage; 027import org.apache.reef.wake.remote.impl.ObjectSerializableCodec; 028import org.apache.reef.wake.remote.impl.TransportEvent; 029 030/** 031 * Configuration options and helper methods for Wake remoting. 032 */ 033public final class RemoteConfiguration { 034 035 /** 036 * The number of tries to reconnect the remote connection. 037 */ 038 public static final long REMOTE_CONNECTION_NUMBER_OF_RETRIES = 3; 039 040 /** 041 * The timeout of connection retrying. 042 * To prevent retrying connections from being rejected by the remote stages, 043 * the retrying_timeout * number_of_retries should be less than the remote_executor_shutdown_timeout. 044 * If not, the remote stage can shutdown the connection retries before it is established, 045 * and can drop a message that should be sent to the remote. 046 */ 047 public static final long REMOTE_CONNECTION_RETRY_TIMEOUT = 048 WakeParameters.REMOTE_EXECUTOR_SHUTDOWN_TIMEOUT / (REMOTE_CONNECTION_NUMBER_OF_RETRIES + 1); 049 050 private RemoteConfiguration() { 051 // empty 052 } 053 054 /** 055 * The name of the remote manager. 056 */ 057 @NamedParameter(short_name = "rm_name", doc = "The name of the remote manager.", default_value = "REEF_CLIENT") 058 public static final class ManagerName implements Name<String> { 059 // Intentionally empty 060 } 061 062 /** 063 * The host address to be used for messages. 064 */ 065 @NamedParameter(short_name = "rm_host", doc = "The host address to be used for messages.", 066 default_value = "##UNKNOWN##") 067 public static final class HostAddress implements Name<String> { 068 // Intentionally empty 069 } 070 071 /** 072 * The port to be used for messages. 073 */ 074 @NamedParameter(short_name = "rm_port", doc = "The port to be used for messages.", default_value = "0") 075 public static final class Port implements Name<Integer> { 076 // Intentionally empty 077 } 078 079 /** 080 * The codec to be used for messages. 081 */ 082 @NamedParameter(doc = "The codec to be used for messages.", default_class = ObjectSerializableCodec.class) 083 public static final class MessageCodec implements Name<Codec<?>> { 084 // Intentionally empty 085 } 086 087 /** 088 * The event handler to be used for throwables. 089 */ 090 @NamedParameter(doc = "The event handler to be used for throwables.", default_class = DefaultErrorHandler.class) 091 public static final class ErrorHandler implements Name<EventHandler<Throwable>> { 092 // Intentionally empty 093 } 094 095 /** 096 * Whether or not to use the message ordering guarantee. 097 */ 098 @NamedParameter(short_name = "rm_order", 099 doc = "Whether or not to use the message ordering guarantee.", default_value = "true") 100 public static final class OrderingGuarantee implements Name<Boolean> { 101 // Intentionally empty 102 } 103 104 /** 105 * The number of tries. 106 */ 107 @NamedParameter(doc = "The number of tries.", default_value = "" + REMOTE_CONNECTION_NUMBER_OF_RETRIES) 108 public static final class NumberOfTries implements Name<Integer> { 109 // Intentionally empty 110 } 111 112 /** 113 * The timeout of connection retrying. 114 */ 115 @NamedParameter(doc = "The timeout of connection retrying.", default_value = "" + REMOTE_CONNECTION_RETRY_TIMEOUT) 116 public static final class RetryTimeout implements Name<Integer> { 117 // Intentionally empty 118 } 119 120 /** 121 * Client stage for messaging transport. 122 */ 123 @NamedParameter(doc = "Client stage for messaging transport.", default_class = DefaultTransportEStage.class) 124 public static final class RemoteClientStage implements Name<EStage<TransportEvent>> { 125 // Intentionally empty 126 } 127 128 /** 129 * Server stage for messaging transport. 130 */ 131 @NamedParameter(doc = "Server stage for messaging transport.", default_class = DefaultTransportEStage.class) 132 public static final class RemoteServerStage implements Name<EStage<TransportEvent>> { 133 // Intentionally empty 134 } 135}