Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / tools / development / Server.java
blob3e1ad216f244011f74080d912273b22bfb112908
1 package com.google.appengine.tools.development;
3 import com.google.appengine.tools.development.AbstractServer.InstanceHolder;
5 import java.util.Map;
7 /**
8 * Holder for both configuration and runtime information for a single
9 * {@link DevAppServer} server and all its instances.
12 interface Server {
13 /**
14 * Configure this {@link Server}.
15 * <p>
16 * Note {@link #configure} fits into the {@link DevAppServer} startup
17 * sequence. The user may adjust {@link DevAppServer#setServiceProperties}
18 * values after construction and before calling {@link DevAppServer#start()}
19 * which calls {@link #configure}. To retain compatibility operations that
20 * make use of these user specified settings such as port selection must not
21 * not be performed during construction.
22 * @param containerConfigProperties container configuration properties.
23 * @throws Exception
25 void configure(Map<String, Object>containerConfigProperties) throws Exception;
27 /**
28 * Creates the network connections for this {@link Server}.
29 * @throws Exception
31 void createConnection() throws Exception;
33 /**
34 * Starts all the instances for this {@link Server}. Once this returns the
35 * {@link Server} can handle HTTP requests.
36 * @throws Exception
38 void startup() throws Exception;
40 /**
41 * Stops all the instances for this {@link Server}. Once this returns the
42 * {@link Server} cannot handle HTTP requests.
43 * @throws Exception
45 void shutdown() throws Exception;
47 /**
48 * Returns the name for this {@link Server}.
50 String getServerName();
52 /**
53 * Returns the {@link ContainerService} for the primary instance for this
54 * {@link Server}.
56 ContainerService getMainContainer();
58 /**
59 * Returns the {@link LocalServerEnvironment} for the primary instance for
60 * this {@link Server}.
62 LocalServerEnvironment getLocalServerEnvironment();
64 /**
65 * Returns the host and port for the requested instance or null if the
66 * instance does not exist.
67 * @param instance The instance number or {@link LocalEnvironment#MAIN_INSTANCE}.
69 String getHostAndPort(int instance);
71 /**
72 * Returns the requested {@link InstanceHolder} or null if the instance does
73 * not exist.
74 * @param instance the instance number or {@link LocalEnvironment#MAIN_INSTANCE}.
76 InstanceHolder getInstanceHolder(int instance);
78 /**
79 * Returns true if the supplied instance is a load balancing server.
80 * @param instance the instance number or {@link LocalEnvironment#MAIN_INSTANCE}.
82 boolean isServerLoadBalancingServer(int instance);
84 /**
85 * Returns the number of instances for this server. This will return 0 for
86 * an {@link AutomaticServer}.
88 int getInstanceCount();
90 /**
91 * Returns the id of an instance for the next request or -1 if there are no
92 * free instances.
94 int getFreeInstance();