| 1 | /** |
| 2 | * |
| 3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
| 4 | * |
| 5 | * ==================================================================== |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * ==================================================================== |
| 18 | */ |
| 19 | package org.jclouds.scriptbuilder.domain; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | import java.net.URI; |
| 24 | |
| 25 | /** |
| 26 | * Defines the environment of a process that can be started in the background on an operating |
| 27 | * system. |
| 28 | * |
| 29 | * @author Adrian Cole |
| 30 | */ |
| 31 | public class InitMetadata { |
| 32 | |
| 33 | private final String name; |
| 34 | private final String platformHome; |
| 35 | private final URI endPoint; |
| 36 | private final String startDir; |
| 37 | private final String stopDir; |
| 38 | private final String configDir; |
| 39 | private final String dataDir; |
| 40 | private final String logDir; |
| 41 | private final String goldDir; |
| 42 | |
| 43 | public InitMetadata(String name, String platformHome, URI endPoint, String startDir, |
| 44 | String stopDir, String configDir, String dataDir, String logDir, String goldDir) { |
| 45 | this.name = checkNotNull(name, "name"); |
| 46 | this.platformHome = checkNotNull(platformHome, "platformHome"); |
| 47 | this.endPoint = endPoint; |
| 48 | this.startDir = checkNotNull(startDir, "startDir"); |
| 49 | this.stopDir = checkNotNull(stopDir, "stopDir"); |
| 50 | this.configDir = checkNotNull(configDir, "configDir"); |
| 51 | this.dataDir = checkNotNull(dataDir, "dataDir"); |
| 52 | this.logDir = checkNotNull(logDir, "logDir"); |
| 53 | this.goldDir = checkNotNull(goldDir, "goldDir"); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * working directory when starting the server. |
| 58 | */ |
| 59 | public String getStartDir() { |
| 60 | return startDir; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * working directory when stopping the server. |
| 65 | */ |
| 66 | public String getStopDir() { |
| 67 | return stopDir; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Where the platform that this process is an instance of is located. This is analogous to the |
| 72 | * CATALINA_HOME on the tomcat platform. |
| 73 | */ |
| 74 | public String getPlatformHome() { |
| 75 | return platformHome; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * what uniquely identifies your process in a listing. Note that this will become a part of the |
| 80 | * process args. |
| 81 | */ |
| 82 | public String getName() { |
| 83 | return name; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * holds configuration files of the process. These are generated or copied from data in the |
| 88 | * {@link #getGoldDir gold copy directory}. |
| 89 | */ |
| 90 | public String getConfigDir() { |
| 91 | return configDir; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * holds files that are generated at runtime, but are not temporary. Ex. customer data, state, |
| 96 | * etc. These files survive recreation of the instance. |
| 97 | */ |
| 98 | public String getDataDir() { |
| 99 | return dataDir; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * where all logs are written. The following files are created here: |
| 104 | * <ul> |
| 105 | * <li>stdout.log - where stdout is piped to upon start.</li> |
| 106 | * <li>stderr.log - where stderr is piped to upon start.</li> |
| 107 | * <li>pid.log - holds the process id, if the process is running.</li> |
| 108 | * </ul> |
| 109 | */ |
| 110 | public String getLogDir() { |
| 111 | return logDir; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * on-disk, read-only location of the artifacts needed to recreate this process. |
| 116 | */ |
| 117 | public String getGoldDir() { |
| 118 | return goldDir; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * the named ip and port that this process will bind server sockets to, as well the protocol used |
| 123 | * to test it. |
| 124 | */ |
| 125 | public URI getEndPoint() { |
| 126 | return endPoint; |
| 127 | } |
| 128 | |
| 129 | } |