mycq.CQManager Interface Reference

Manages continuous queries of a MyCQ Server. More...

List of all members.

Public Member Functions

void createCQ (String cqName, String cqStatement, int cqResultQueueSize) throws MyCQException
 Create a CQ(Continuous Query) and CQResultQueue in a MyCQ Server.
void deleteCQ (String cqName) throws MyCQException
 Delete a CQ(Continuous Query).
void deleteAllCQ () throws MyCQException
 Delete all CQ(Continuous Query)s in a MyCQ Server.
String getCQStatement (String cqName) throws MyCQException
 Get a CQ(Continuous Query) statement in a MyCQ Server.
void setHeartBeat (int msec) throws MyCQException
 Set heart beat. (Heart beat is the speed value of continuous query scheduling.).
int getHeartBeat () throws MyCQException
 Get heart beat. (Heart beat is the speed value of continuous query scheduling.).
List< String > getAllCQNames () throws MyCQException
 Get all CQ(Continuous Query) names in a MyCQ Server.
List< String > getCQNamesByQueueName (String queueName) throws MyCQException
 Get all CQ(Continuous Query) names related to a queue name in a MyCQ Server.

Detailed Description

Manages continuous queries of a MyCQ Server.

import java.util.List;
import mycq.*;

public class ExamCQManager {

            void examSetQueueSchema(QueueSchema queueSchema) {
                        try {
                                    queueSchema.addBoolean("boolean");
                                    queueSchema.addByte("byte");
                                    queueSchema.addShort("short");
                                    queueSchema.addUShort("ushort");
                                    queueSchema.addInt("int");
                                    queueSchema.addLong("long");
                                    queueSchema.addFloat("float");
                                    queueSchema.addDouble("double");
                                    queueSchema.addDate("date");
                                    queueSchema.addTime("time");
                                    queueSchema.addDateTime("datetime");
                                    queueSchema.addString("string", 100);
                                    queueSchema.addVarString("varstring");
                                    queueSchema.addBinary("binary", 100);
                                    queueSchema.addVarBinary("varbinary");
                        } catch (MyCQException ex) {
                                    System.out.println("code:" + ex.getCode() + ", message:"
                                                            + ex.getMessage());
                        }
                        
                        // columns
                        // col 0: boolean
                        // col 1: byte
                        // col 2: short
                        // col 3: ushort
                        // col 4: int
                        // col 5: long
                        // col 6: float
                        // col 7: double
                        // col 8: date
                        // col 9: time
                        // col10: datetime
                        // col11: string
                        // col12: varstring
                        // col13: binary
                        // col14: varbinary                 
            }

            public void sample() {
                        // get client instance
                        MyCQClient client = MyCQFactory.getMyCQClient();

                        try {
                                    // connect
                                    client.connect("localhost", 3030, "root", "1234");

                                    // get queue manager
                                    QueueManager queueManager = client.getQueueManager();

                                    // get cq manager
                                    CQManager cqManager = client.getCQManager();

                                    cqManager.deleteAllCQ();
                                    queueManager.deleteAllQueues();

                                    // Queue Schema
                                    // get queue schema instance
                                    QueueSchema queueSchema = MyCQFactory.getQueueSchema();

                                    // set queue schema
                                    examSetQueueSchema(queueSchema);

                                    // create queues for CQ
                                    queueManager.createP2PQueue("p2pQueue", queueSchema, 100);
                                    queueManager.createTopicQueue("topicQueue", queueSchema, 100);

                                    // create cq
                                    String cq1 = "window p2pQueue as win1[size=30sec, slide=30sec] select count(*) from win1";
                                    cqManager.createCQ("cq1", cq1, 100);

                                    // create cq
                                    String cq2 = "window topicQueue as win1[size=30sec, slide=30sec] select count(*) from win1";
                                    cqManager.createCQ("cq2", cq2, 100);

                                    // get all cq names
                                    List<String> result;
                                    result = cqManager.getAllCQNames();
                                    for (String str : result) {
                                                System.out.println(str);
                                                System.out.println(cqManager.getCQStatement(str));
                                    }

                                    // get cq names by queue name
                                    result = cqManager.getCQNamesByQueueName("p2pQueue");
                                    for (String str : result) {
                                                System.out.println(str);
                                    }

                                    // set heart beat, get heart beat
                                    cqManager.setHeartBeat(500);
                                    System.out.println("heart beat:" + cqManager.getHeartBeat());

                                    cqManager.setHeartBeat(1000);
                                    System.out.println("heart beat:" + cqManager.getHeartBeat());

                                    // delete cq
                                    cqManager.deleteCQ("cq1");

                                    // delete all cq
                                    cqManager.deleteAllCQ();

                                    // delete all queues
                                    queueManager.deleteAllQueues();

                        } catch (MyCQException ex) {
                                    System.out.println("code:" + ex.getCode() + ", message:"
                                                            + ex.getMessage());
                        }

                        // close connection
                        client.close();
            }
}

Member Function Documentation

void mycq.CQManager.createCQ ( String  cqName,
String  cqStatement,
int  cqResultQueueSize 
) throws MyCQException

Create a CQ(Continuous Query) and CQResultQueue in a MyCQ Server.

Parameters:
cqName A continuous query name to create. CQResultQueue name will be the equal name to cq name. (size:= under 64). A cq name is a combination of alphabets and numerics which starts with alphabet character.
cqStatement A continuous query statement. See MyCQL documents.
cqResultQueueSize An integer greater than zero that will be the size of a CQResultQueue to be created.
Exceptions:
MyCQException An error occurred while creating a new continuos query.
void mycq.CQManager.deleteAllCQ (  )  throws MyCQException

Delete all CQ(Continuous Query)s in a MyCQ Server.

Exceptions:
MyCQException An error occurred while deleting all the CQs.
void mycq.CQManager.deleteCQ ( String  cqName  )  throws MyCQException

Delete a CQ(Continuous Query).

Parameters:
cqName A continuous query name to delete.
Exceptions:
MyCQException An error occurred while deleting a continuos query.
List<String> mycq.CQManager.getAllCQNames (  )  throws MyCQException

Get all CQ(Continuous Query) names in a MyCQ Server.

Returns:
CQ name list.
Exceptions:
MyCQException An error occurred while getting all the cq names.
List<String> mycq.CQManager.getCQNamesByQueueName ( String  queueName  )  throws MyCQException

Get all CQ(Continuous Query) names related to a queue name in a MyCQ Server.

Parameters:
queueName A queue name.
Returns:
CQ name list.
Exceptions:
MyCQException An error occurred while getting all the cq names.
String mycq.CQManager.getCQStatement ( String  cqName  )  throws MyCQException

Get a CQ(Continuous Query) statement in a MyCQ Server.

Parameters:
cqName A continuous query name.
Returns:
CQ statement.
Exceptions:
MyCQException An error occurred while getting a cq statement.
int mycq.CQManager.getHeartBeat (  )  throws MyCQException

Get heart beat. (Heart beat is the speed value of continuous query scheduling.).

Returns:
An integer(msec>=0) value of miliseconds.
Exceptions:
MyCQException An error occurred while getting a heart beat.
void mycq.CQManager.setHeartBeat ( int  msec  )  throws MyCQException

Set heart beat. (Heart beat is the speed value of continuous query scheduling.).

Parameters:
msec An integer(msec>=0) value of miliseconds.
Exceptions:
MyCQException An error occurred while setting a heart beat.
 All Classes Namespaces Functions Variables Enumerations
MyCQ Java User's Document. Copyright@MyCQ Inc., All Rights Reserved.