Beispiel #1
0
void PopulateLifos( Session & session, vector<myLifo> & l )
{
   int i, j;
   string data;
   char s[4];
   psoObjectDefinition queueDef = { PSO_LIFO, 0, 0, 0 };
   
   for ( i = 0; i < NUM_LIFOS; ++i ) {
      session.CreateQueue( l[i].name, queueDef, "Default" );
      l[i].queue.Open( session, l[i].name );

      for ( j = 0; j < 20; ++j ) {
         sprintf(s, "%d", j);
         data = string("Inserted data item = ") + s;
         sprintf(s, "%d", i);
         data += string(" in queue = ") + s;
         l[i].queue.Push( data.c_str(), data.length() );
      }
   }

   session.Commit();
}
Beispiel #2
0
void PopulateQueues( Session & session, vector<myQueue> & q )
{
   int i, j;
   string data;
   char s[4];
   psoObjectDefinition queueDef = { PSO_QUEUE, 0, 0, 0 };
   
   for ( i = 0; i < NUM_QUEUES; ++i ) {
      cout << " i = " << i << ", " << q[i].name << ", " << &session << endl;
      session.CreateQueue( q[i].name, queueDef, "Default" );
      q[i].queue.Open( session, q[i].name );

      for ( j = 0; j < 20; ++j ) {
         sprintf(s, "%d", j);
         data = string("Inserted data item = ") + s;
         sprintf(s, "%d", i);
         data += string(" in queue = ") + s;
         q[i].queue.Push( data.c_str(), data.length() );
      }
   }

   session.Commit();
}
Beispiel #3
0
int main( int argc, char * argv[] )
{
   Process process;
   Session session;
   Queue * queue;
   string fname = "/cpp_queue_status";
   string qname = fname + "/test";
   const char * data1 = "My Data1";
   const char * data2 = "My Data2";
   const char * data3 = "My Data3";
   psoObjStatus status;
   psoObjectDefinition queueDef = { PSO_QUEUE, 0, 0, 0 };
   psoFieldDefinition fields[1] = {
      { "Field_1", PSO_VARCHAR, {10} }
   };

   try {
      if ( argc > 1 ) {
         process.Init( argv[1], argv[0] );
      }
      else {
         process.Init( "10701", argv[0] );
      }
   }
   catch( pso::Exception exc ) {
      cerr << "Test failed in init phase, error = " << exc.Message() << endl;
      cerr << "Is the server running?" << endl;
      return 1;
   }

   try {
      session.Init();
      session.CreateFolder( fname );

      DataDefinition dataDefObj( session, 
                                 "cpp_queue_status",
                                 PSO_DEF_PHOTON_ODBC_SIMPLE,
                                 (unsigned char *)fields,
                                 sizeof(psoFieldDefinition) );
      session.CreateQueue( qname,
                           queueDef,
                           dataDefObj );
      queue = new Queue( session, qname );
      queue->Push( data1, strlen(data1) );
      queue->Push( data2, strlen(data2) );
      queue->Push( data3, strlen(data3) );
   }
   catch( pso::Exception exc ) {
      cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
      return 1;
   }

   // End of invalid args. This call should succeed.
   try {
      queue->Status( status );
   }
   catch( pso::Exception exc ) {
      cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
      return 1;
   }

   if ( status.numDataItem != 3 ) {
      cerr << "Test failed - line " << __LINE__ << endl;
      return 1;
   }
   if ( status.numBlocks != 1 ) {
      cerr << "Test failed - line " << __LINE__ << endl;
      return 1;
   }
   if ( status.numBlockGroup != 1 ) {
      cerr << "Test failed - line " << __LINE__ << endl;
      return 1;
   }
   if ( status.freeBytes == 0 || status.freeBytes >=PSON_BLOCK_SIZE ) {
      cerr << "Test failed - line " << __LINE__ << endl;
      return 1;
   }

   return 0;
}