|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.equilibrium.util.api.MGConnection
public class MGConnection
A connection to a MediaGenerator.
Creates a persistent socket connection to the Media Generator which can be used to service multiple MediaGenerator requests.
A connection is established to a Media Generator by instantiating a MGConnection object. The constructor can be called with no arguments to connect to a Media Generator running on the same machine as the client program. To connect to a Generator on another machine, the name or IP of that machine is passed to the constructor. A port number can also be passed to the constructor. This is only necessary if the MediaGenerator is listening for requests on a non-standard port number.
Two kinds of jobs can be submitted to the MediaGenerator; 1) simple requests and 2) batch jobs.
Simple Requests
Simple requests consist of the execution of a single script. These requests are synchronous. That is, the client must block while the requested operation is performed if it wishes to receive back any results from the request.
Simple requests begin by calling the createRequest() method on the MGConnection
object. This method returns a MGRequest object. Refer
to the documentation for
that object for more information on submitting simple requests.
Batch Requests
Batch requests consist of a series of individual script executions that together define a single batch operation. Batch operations are executed asynchronously. That is, once the client has fully defined and submitted a batch request, it can go on and do other things. In this case, the client will normally contact the Media Generator periodically to check on the status of the batch jobs it has submitted. When it sees that a batch job has been completed, it may choose to make additional requests to the Media Generator to obtain the results of the batch operation.
To submit a batch job, the client code calls the createBatch() method on the
MGConnection object. This method returns a MGBatch object. Refer to the documentation for
that object for more information on submitting batch jobs.
MGRequest,
MGBatch| Nested Class Summary | |
|---|---|
static class |
MGConnection.Flags
Flags intended for use with various methods on the MGConnection class. |
| Constructor Summary | |
|---|---|
MGConnection()
Construct a default (localhost:9877) connection |
|
MGConnection(java.lang.String hostname)
Construct a connection with the specified host and default port. |
|
MGConnection(java.lang.String hostname,
int port)
Construct a connection to the specified host and port. |
|
MGConnection(java.lang.String hostname,
int port,
int timeout)
Construct a connection to the specified host and port with the specified timeout. |
|
| Method Summary | |
|---|---|
void |
batchAbort(int batchId,
java.lang.String batchName)
Abort the specified batch. |
MGBatchesExecutingResponse |
batchesExecuting()
Return the ids of the batches currently executing. |
void |
batchForget(int batchID)
Tell the server to forget about the batch with the specified id. |
MGBatchStatusResponse |
batchStatus(int batchID)
Return the batch status of the batch with the specified id. |
MGBatchStatusResponse |
batchStatus(int batchID,
int flags)
Return the batch status of the batch with the specified id based on the specified flags. |
void |
close()
Close and cleanup this connection. |
MGBatch |
createBatch()
Create an unnamed Batch. |
MGBatch |
createBatch(java.lang.String batchName)
Create a named Batch. |
MGBatch |
createBatch(java.lang.String batchName,
boolean trackCompletedJobs)
Create a named Batch and specify whether to track completed jobs. |
MGRequest |
createRequest()
Create a new request. |
int |
getConnectionTimeout()
Return this connection's timeout value. |
java.lang.String |
getHostName()
Return the host name for this connection. |
int |
getPort()
Return the port for this connection. |
MGFileResponse |
requestFile(java.lang.String path)
Create a request for a file from the MediaGenerator. |
MGFileResponse |
requestFile(java.lang.String path,
int offset)
Create a request for a file from the MediaGenerator. |
long |
requestSessionId()
Return the session ID for this request. |
MGFileResponse |
requestSharedFile(java.lang.String path,
int offset)
Create a request for a file from the MediaGenerator. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MGConnection()
throws java.io.IOException
java.io.IOException
public MGConnection(java.lang.String hostname)
throws java.io.IOException
hostname - the host to connect to.
java.io.IOException
public MGConnection(java.lang.String hostname,
int port)
throws java.io.IOException
hostname - the host.port - the port.
java.io.IOException
public MGConnection(java.lang.String hostname,
int port,
int timeout)
throws java.io.IOException
hostname - the hostname for the MediaGenerator.port - the porttimeout - the number of milliseconds to wait.
java.io.IOException| Method Detail |
|---|
public java.lang.String getHostName()
public int getPort()
public int getConnectionTimeout()
public MGRequest createRequest()
throws java.io.IOException
java.io.IOException
public MGBatch createBatch()
throws java.io.IOException,
MGException
java.io.IOException
MGException
public MGBatch createBatch(java.lang.String batchName,
boolean trackCompletedJobs)
throws java.io.IOException,
MGException
batchName - the batch name.trackCompletedJobs - if true retain status about jobs after batch ends.
java.io.IOException
MGExceptionMGConnection.createBatch()
public MGBatch createBatch(java.lang.String batchName)
throws java.io.IOException,
MGException
batchName - the batch name.
java.io.IOException
MGExceptionMGConnection.createBatch()
public MGFileResponse requestFile(java.lang.String path)
throws java.io.IOException,
MGException
path - the path to the file.
java.io.IOException
MGException
public MGFileResponse requestSharedFile(java.lang.String path,
int offset)
throws java.io.IOException,
MGException
path - the path to the file.offset - the offset at which to start reading the file.
java.io.IOException
MGException
public MGFileResponse requestFile(java.lang.String path,
int offset)
throws java.io.IOException,
MGException
path - the path to the file.offset - the offset at which to start reading the file.
java.io.IOException
MGException
public MGBatchStatusResponse batchStatus(int batchID,
int flags)
throws java.io.IOException,
MGException
batchID - the batch id for the batch.flags - flags that determine what information is returned
java.io.IOException
MGExceptionMGConnection.Flags
public MGBatchStatusResponse batchStatus(int batchID)
throws java.io.IOException,
MGException
batchID - the batch id for the batch.
java.io.IOException
MGException
public void batchForget(int batchID)
throws java.io.IOException,
MGException
batchID - the batch id for the batch.
java.io.IOException
MGException
public MGBatchesExecutingResponse batchesExecuting()
throws java.io.IOException,
MGException
java.io.IOException
MGException
public void batchAbort(int batchId,
java.lang.String batchName)
throws java.io.IOException
batchId - the id for the batch to be aborted.batchName - the name of the batch to be aborted.
java.io.IOException
public void close()
throws java.io.IOException
java.io.IOException
public long requestSessionId()
throws MGException
MGException
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||