Class TestServer
- java.lang.Object
-
- com.yahoo.messagebus.network.rpc.test.TestServer
-
public class TestServer extends java.lang.Object
A simple test server implementation.- Author:
- Haavard Pettersen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TestServer.VersionedRPCNetwork
-
Field Summary
Fields Modifier and Type Field Description MessageBus
mb
TestServer.VersionedRPCNetwork
net
-
Constructor Summary
Constructors Constructor Description TestServer(MessageBusParams mbusParams, RPCNetworkParams netParams)
Create a new test server.TestServer(java.lang.String name, RoutingTableSpec table, com.yahoo.jrt.slobrok.server.Slobrok slobrok, Protocol protocol)
Create a new test server.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
destroy()
Sets the destroyed flag to true.static java.lang.String
getSlobrokConfig(com.yahoo.jrt.slobrok.server.Slobrok slobrok)
Returns the raw config needed to connect to the given slobrok.void
setupRouting(RoutingTableSpec table)
Proxies theMessageBus.setupRouting(RoutingSpec)
method by encapsulating the given table specification within the requiredRoutingSpec
.boolean
waitSlobrok(java.lang.String pattern, int cnt)
Wait for some pattern to resolve to some number of services.boolean
waitState(SlobrokState slobrokState)
Wait for a required slobrok state.
-
-
-
Field Detail
-
net
public final TestServer.VersionedRPCNetwork net
-
mb
public final MessageBus mb
-
-
Constructor Detail
-
TestServer
public TestServer(java.lang.String name, RoutingTableSpec table, com.yahoo.jrt.slobrok.server.Slobrok slobrok, Protocol protocol)
Create a new test server.- Parameters:
name
- The service name prefix for this server.table
- The routing table spec to be used, may be null for no routing.slobrok
- The slobrok to register with (local).protocol
- The protocol that this server should support in addition to SimpleProtocol.
-
TestServer
public TestServer(MessageBusParams mbusParams, RPCNetworkParams netParams)
Create a new test server.- Parameters:
mbusParams
- The parameters for mesasge bus.netParams
- The parameters for the rpc network.
-
-
Method Detail
-
destroy
public boolean destroy()
Sets the destroyed flag to true. The very first time this method is called, it cleans up all its dependencies. Even if you retain a reference to this object, all of its content is allowed to be garbage collected.- Returns:
- True if content existed and was destroyed.
-
getSlobrokConfig
public static java.lang.String getSlobrokConfig(com.yahoo.jrt.slobrok.server.Slobrok slobrok)
Returns the raw config needed to connect to the given slobrok.- Parameters:
slobrok
- The slobrok whose connection spec to include.- Returns:
- The raw config string.
-
setupRouting
public void setupRouting(RoutingTableSpec table)
Proxies theMessageBus.setupRouting(RoutingSpec)
method by encapsulating the given table specification within the requiredRoutingSpec
.- Parameters:
table
- The table to configure.
-
waitSlobrok
public boolean waitSlobrok(java.lang.String pattern, int cnt)
Wait for some pattern to resolve to some number of services.- Parameters:
pattern
- Pattern to lookup in slobrok.cnt
- Number of services it must resolve to.- Returns:
- Whether or not the required state was reached.
-
waitState
public boolean waitState(SlobrokState slobrokState)
Wait for a required slobrok state.- Parameters:
slobrokState
- The state to wait for.- Returns:
- Whether or not the required state was reached.
-
-