1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.spark.launcher; 19 20 import java.io.Serializable; 21 22 /** 23 * Message definitions for the launcher communication protocol. These messages must remain 24 * backwards-compatible, so that the launcher can talk to older versions of Spark that support 25 * the protocol. 26 */ 27 final class LauncherProtocol { 28 29 /** Environment variable where the server port is stored. */ 30 static final String ENV_LAUNCHER_PORT = "_SPARK_LAUNCHER_PORT"; 31 32 /** Environment variable where the secret for connecting back to the server is stored. */ 33 static final String ENV_LAUNCHER_SECRET = "_SPARK_LAUNCHER_SECRET"; 34 35 static class Message implements Serializable { 36 37 } 38 39 /** 40 * Hello message, sent from client to server. 41 */ 42 static class Hello extends Message { 43 44 final String secret; 45 final String sparkVersion; 46 Hello(String secret, String version)47 Hello(String secret, String version) { 48 this.secret = secret; 49 this.sparkVersion = version; 50 } 51 52 } 53 54 /** 55 * SetAppId message, sent from client to server. 56 */ 57 static class SetAppId extends Message { 58 59 final String appId; 60 SetAppId(String appId)61 SetAppId(String appId) { 62 this.appId = appId; 63 } 64 65 } 66 67 /** 68 * SetState message, sent from client to server. 69 */ 70 static class SetState extends Message { 71 72 final SparkAppHandle.State state; 73 SetState(SparkAppHandle.State state)74 SetState(SparkAppHandle.State state) { 75 this.state = state; 76 } 77 78 } 79 80 /** 81 * Stop message, send from server to client to stop the application. 82 */ 83 static class Stop extends Message { 84 85 } 86 87 } 88