Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / tools / development / Server.java
blobae816dbbf064b8d4a683eb47eb7a85a9fa85e6b8
1 package com.google.appengine.tools.development;
3 import java.util.Map;
5 /**
6 * Holder for both configuration and runtime information for a single
7 * {@link DevAppServer} server and all its instances.
9 */
10 interface Server {
11 /**
12 * Configure this {@link Server}.
13 * <p>
14 * Note {@link #configure} fits into the {@link DevAppServer} startup
15 * sequence. The user may adjust {@link DevAppServer#setServiceProperties}
16 * values after construction and before calling {@link DevAppServer#start()}
17 * which calls {@link #configure}. To retain compatibility operations that
18 * make use of these user specified settings such as port selection must not
19 * not be performed during construction.
20 * @param containerConfigProperties container configuration properties.
21 * @throws Exception
23 void configure(Map<String, Object>containerConfigProperties) throws Exception;
25 /**
26 * Creates the network connections for this {@link Server}.
27 * @throws Exception
29 void createConnection() throws Exception;
31 /**
32 * Starts all the instances for this {@link Server}. Once this returns the
33 * {@link Server} can handle HTTP requests.
34 * @throws Exception
36 void startup() throws Exception;
38 /**
39 * Stops all the instances for this {@link Server}. Once this returns the
40 * {@link Server} cannot handle HTTP requests.
41 * @throws Exception
43 void shutdown() throws Exception;
45 /**
46 * Simulates stopping the server in production.
48 * @throws UnsupportedOperationException if this is not a manual server.
49 * @throws Exception
51 void stopServing() throws Exception;
53 /**
54 * Simulates starting the server in production.
56 * @throws UnsupportedOperationException if this is not a manual server.
57 * @throws Exception
59 void startServing() throws Exception;
61 /**
62 * Returns the name for this {@link Server}.
64 String getServerName();
66 /**
67 * Returns the {@link ContainerService} for the primary instance for this
68 * {@link Server}.
70 ContainerService getMainContainer();
72 /**
73 * Returns the {@link LocalServerEnvironment} for the primary instance for
74 * this {@link Server}.
76 LocalServerEnvironment getLocalServerEnvironment();
78 /**
79 * Returns the host and port for the requested instance or null if the
80 * instance does not exist.
81 * @param instance The instance number or {@link LocalEnvironment#MAIN_INSTANCE}.
83 String getHostAndPort(int instance);
85 /**
86 * Returns the requested {@link InstanceHolder} or null if the instance does
87 * not exist.
88 * @param instance the instance number or {@link LocalEnvironment#MAIN_INSTANCE}.
90 InstanceHolder getInstanceHolder(int instance);
92 /**
93 * Returns the number of instances for this server. This will return 0 for
94 * an {@link AutomaticServer}.
96 int getInstanceCount();
98 /**
99 * Acquires a serving permit and returns an {@link InstanceHolder} for an
100 * instance which is available to handle a request or returns null if there
101 * is no such instance.
102 * <p>
103 * throws {@link UnsupportedOperationException} unless this is a
104 * {@link ManualServer}.
106 InstanceHolder getAndReserveAvailableInstanceHolder();