本文整理汇总了C++中Process::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::Init方法的具体用法?C++ Process::Init怎么用?C++ Process::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::Init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
Folder * folder;
string name = "/cpp_folder_create";
string subname = "test";
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( name );
folder = new Folder( session, name );
}
catch( pso::Exception exc ) {
cerr << "Test failed in init phase, error = " << exc.Message() << endl;
cerr << "Is the server running?" << endl;
return 1;
}
// Invalid arguments to tested function.
try {
folder->CreateFolder( "" );
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
// End of invalid args. This call should succeed.
try {
folder->CreateFolder( subname );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
return 0;
}
示例2: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
// Internal process object not initialized
try {
session.Init();
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_PROCESS_NOT_INITIALIZED ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
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();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
return 0;
}
示例3: main
int main(int argc, char* argv[])
{
Process process;
char* pos = NULL;
pos = strrchr(argv[0],'/');
if( pos != NULL )
{
pos++;
log.Init(pos);
}
else
log.Init(argv[0]);
if(process.Init() == false)
{
cout<<"Init Process error"<<endl;
return 0;
}
if( openDB() == false )
return 1;
//////
////
LibVirtEventHandle handle;
if( handle.init() == false )
{
cout<<"Init LibVirtEventHandle error"<<endl;
return 0;
}
if( handle.begin() == false )
return 0;
/////////
NCHeartBeat nh;
if( nh.init() == false)
return 0;
if( nh.begin() == false)
return 0;
process.Do();
return 0;
}
示例4: main
int main()
{
Process process;
Session session;
int i, rc;
psoObjectDefinition folderDef;
memset( &folderDef, 0, sizeof folderDef );
folderDef.type = PSO_FOLDER;
try {
process.Init( "10701", "InjectErrors" );
session.Init();
session.CreateFolder( foldername );
}
catch( pso::Exception exc ) {
rc = exc.ErrorCode();
if ( rc == PSO_OBJECT_ALREADY_PRESENT ) {
CleanupPreviousRun( session );
}
else {
cerr << "Init Photon failed, error = " << exc.Message() << endl;
if ( rc == PSO_CONNECT_ERROR ) cerr << "Is the server running?" << endl;
return 1;
}
}
cout << " ------- Photon defects injector ------- " << endl << endl;
cout << " This program will inject pseudo-random defects in a shared memory." << endl << endl;
vector<myQueue> q( NUM_QUEUES, myQueue() );
vector<myMap> h( NUM_MAPS, myMap() );
vector<myLifo> l( NUM_LIFOS, myLifo() );
for ( i = 0; i < NUM_QUEUES; ++ i ) {
q[i].name += ('0' + i/10 );
q[i].name += ('0' + (i%10) );
}
for ( i = 0; i < NUM_MAPS; ++i ) {
h[i].name += ('0' + i/10 );
h[i].name += ('0' + (i%10) );
}
for ( i = 0; i < NUM_LIFOS; ++i ) {
l[i].name += ('0' + i/10 );
l[i].name += ('0' + (i%10) );
}
try {
PopulateQueues( session, q );
PopulateHashMaps( session, h );
PopulateLifos( session, l );
}
catch( pso::Exception exc ) {
cerr << "Creating and populating the objects failed, error = " << exc.Message() << endl;
return 1;
}
cout << "Queues, maps, etc. are created and populated." << endl << endl;
rc = AddDefectsQueues( q );
if ( rc != 0 ) {
cerr << "Adding defect to queues failed!" << endl;
return 1;
}
cout << "All defects were added to queues." << endl << endl;
rc = AddDefectsHashMaps( h );
if ( rc != 0 ) {
cerr << "Adding defect to hash maps failed!" << endl;
return 1;
}
cout << "All defects were added to hash maps." << endl << endl;
rc = AddDefectsLifos( l );
if ( rc != 0 ) {
cerr << "Adding defect to LIFO queues failed!" << endl;
return 1;
}
cout << "All defects were added to LIFO queues." << endl << endl;
return 0;
}
示例5: main
int main( int argc, char * argv[] )
{
Process process;
Session session1, session2;
FastMapEditor * editor;
FastMap * hashmap;
string fname = "/cpp_fastmap_get";
string hname = fname + "/test";
const char * key = "My Key";
const char * data = "My Data";
uint32_t length;
char buffer[50];
psoObjectDefinition mapDef = { PSO_FAST_MAP, 0, 0, 0 };
psoKeyFieldDefinition keys = { "MyKey", PSO_KEY_VARBINARY, 20 };
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 {
session1.Init();
session2.Init();
session2.CreateFolder( fname );
DataDefinition dataDefObj( session2,
"cpp_fastmap_get",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)fields,
sizeof(psoFieldDefinition) );
KeyDefinition keyDefObj( session2,
"cpp_fastmap_get",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)&keys,
sizeof(psoKeyFieldDefinition) );
session2.CreateMap( hname, mapDef, dataDefObj, keyDefObj );
session2.Commit();
hashmap = new FastMap( session1, hname );
editor = new FastMapEditor( session2, hname );
editor->Insert( key, strlen(key), data, strlen(data) );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Invalid arguments to tested function.
try {
// No commit yet.
hashmap->Get( key, strlen(key), buffer, 50, length );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NO_SUCH_ITEM ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
editor->Close();
session2.Commit(); // Commit the editions
session1.Commit(); // Refresh session1 (and hashmap)
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
try {
hashmap->Get( NULL, strlen(key), buffer, 50, length );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_POINTER ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
hashmap->Get( key, 0, buffer, 50, length );
//.........这里部分代码省略.........
示例6: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
DataDefinition * pDataDef = NULL;
string name = "/cpp_datadefinition_create";
unsigned char byteData[50];
unsigned int dataLength = 50;
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;
}
// Session is not initialized
try {
pDataDef = new DataDefinition( session,
name,
PSO_DEF_USER_DEFINED,
byteData,
dataLength );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_HANDLE ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
session.Init();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Wrong arguments to tested function
try {
pDataDef = new DataDefinition( session,
"",
PSO_DEF_USER_DEFINED,
byteData,
dataLength );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
pDataDef = new DataDefinition( session,
"Default",
PSO_DEF_USER_DEFINED,
byteData,
dataLength );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_ITEM_ALREADY_PRESENT ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
pDataDef = new DataDefinition( session,
name,
(psoDefinitionType)0,
byteData,
dataLength );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_WRONG_OBJECT_TYPE ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
//.........这里部分代码省略.........
示例7: main
int main( int argc, char * argv[] )
{
Process process;
Session session1, session2;
Folder folder1, folder2;
Queue queue1, queue2;
string name = "/cpp_session_destroy";
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 {
session1.Init();
session2.Init();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Non-existing object
try {
session1.DestroyObject( name );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NO_SUCH_OBJECT ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
session1.CreateFolder( name );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Destroy without a commit - should fail
try {
session1.DestroyObject( name );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_OBJECT_IS_IN_USE ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
session1.Commit();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Invalid arguments to tested function.
try {
session1.DestroyObject( "" );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
// End of invalid args. This call should succeed.
try {
session1.DestroyObject( name );
}
catch( pso::Exception exc ) {
//.........这里部分代码省略.........
示例8: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
HashMap * hashmap;
string fname = "/cpp_hashmap_definition";
string hname = fname + "/test";
psoObjectDefinition mapDef = { PSO_HASH_MAP, 0, 0, 0 };
psoFieldDefinition fields[5] = {
{ "field1", PSO_TINYINT, {0} },
{ "field2", PSO_INTEGER, {0} },
{ "field3", PSO_CHAR, {30} },
{ "field4", PSO_SMALLINT, {0} },
{ "field5", PSO_LONGVARBINARY, {0} }
};
psoKeyFieldDefinition keys[2] = {
{ "LastName", PSO_KEY_CHAR, 30 },
{ "FirstName", PSO_KEY_VARCHAR, 30 }
};
DataDefinition * retDataDef = NULL;
KeyDefinition * retKeyDef = NULL;
unsigned char * retFields = NULL;
unsigned char * retKeys = NULL;
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_hashmap_definition",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)fields,
5*sizeof(psoFieldDefinition) );
KeyDefinition keyDefObj( session,
"cpp_hashmap_definition",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)keys,
2*sizeof(psoKeyFieldDefinition) );
session.CreateMap( hname, mapDef, dataDefObj, keyDefObj );
hashmap = new HashMap( session, hname );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
try {
retDataDef = hashmap->GetDataDefinition();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
try {
if ( retDataDef->GetType() != PSO_DEF_PHOTON_ODBC_SIMPLE ) {
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
if ( retDataDef->GetLength() != 5*sizeof(psoFieldDefinition) ) {
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
retFields = new unsigned char [5*sizeof(psoFieldDefinition)];
retDataDef->GetDefinition( retFields, 5*sizeof(psoFieldDefinition) );
if ( memcmp( retFields, fields, 5*sizeof(psoFieldDefinition) ) != 0 ) {
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
try {
retKeyDef = hashmap->GetKeyDefinition();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
try {
//.........这里部分代码省略.........
示例9: main
int main( int argc, char * argv[] )
{
Process process;
Session session1, session2;
FastMapEditor * map1;
FastMap * map2;
string fname = "/cpp_fastmap_delete";
string hname = fname + "/test";
const char * key = "My Key";
const char * data = "My Data";
uint32_t length, keyLength;
char buffer[20], keyBuff[20];
int rc;
psoObjectDefinition mapDef = { PSO_FAST_MAP, 0, 0, 0 };
psoKeyFieldDefinition keys = { "MyKey", PSO_KEY_VARBINARY, 20 };
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 {
session1.Init();
session2.Init();
session1.CreateFolder( fname );
DataDefinition dataDefObj( session1,
"cpp_fastmap_delete",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)fields,
sizeof(psoFieldDefinition) );
KeyDefinition keyDefObj( session1,
"cpp_fastmap_delete",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)&keys,
sizeof(psoKeyFieldDefinition) );
session1.CreateMap( hname, mapDef, dataDefObj, keyDefObj );
map1 = new FastMapEditor( session1, hname );
map1->Insert( key, 6, data, 7 );
delete (map1);
session1.Commit();
map1 = new FastMapEditor( session1, hname );
map2 = new FastMap( session2, hname );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Invalid arguments to tested function.
try {
map1->Delete( NULL, 6 );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_POINTER ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
map1->Delete( key, 0 );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
// End of invalid args. This call should succeed.
try {
map1->Delete( key, 6 );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
//.........这里部分代码省略.........
示例10: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
DataDefinition * pDataDef;
string name = "Default";
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;
}
// Session is not initialized
try {
pDataDef = new DataDefinition( session, name );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_HANDLE ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
session.Init();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Wrong arguments to tested function
try {
pDataDef = new DataDefinition( session, "" );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
pDataDef = new DataDefinition( session, "blah-blah-junk" );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NO_SUCH_ITEM ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
// This call should work
try {
pDataDef = new DataDefinition( session, name );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
delete pDataDef;
return 0;
}
示例11: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
int errcode;
string name = "/cpp_session_last_error";
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();
// Is last error properly initialized?
errcode = session.LastError();
if ( errcode != PSO_OK ) {
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
// Our first "test call"
session.CreateFolder( name );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
try {
errcode = session.LastError();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
if ( errcode != PSO_OK ) {
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
// Create the same object a second time and check that last error is
// the one we expect.
try {
session.CreateFolder( name );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_OBJECT_ALREADY_PRESENT ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
errcode = session.LastError();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
if ( errcode != PSO_OBJECT_ALREADY_PRESENT ) {
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
return 0;
}
示例12: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
DataDefinition dataDef;
string name = "/cpp_datadefinition_close";
unsigned char byteData[50];
unsigned int dataLength = 50;
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;
}
// DataDefinition is not initialized
try {
dataDef.Close();
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_HANDLE ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
session.Init();
dataDef.Create( session,
name,
PSO_DEF_USER_DEFINED,
byteData,
dataLength );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
try {
dataDef.Close();
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
return 0;
}
示例13: main
int main( int argc, char * argv[] )
{
Process process;
Session session1, session2;
Lifo queue1, queue2;
string fname = "/cpp_queue_pop";
string qname = fname + "/test";
const char * data1 = "My Data1";
char buffer[50];
uint32_t length;
int rc;
psoObjectDefinition queueDef = { PSO_LIFO, 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 {
session1.Init();
session2.Init();
session1.CreateFolder( fname );
DataDefinition dataDefObj( session1,
"cpp_lifo_pop",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)fields,
sizeof(psoFieldDefinition) );
session1.CreateQueue( qname, queueDef, dataDefObj );
queue1.Open( session1, qname );
queue1.Push( data1, strlen(data1) );
session1.Commit();
queue2.Open( session2, qname );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Invalid arguments to tested function.
try {
queue1.Pop( NULL, 50, length );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_POINTER ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
queue1.Pop( buffer, 2, length );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
// End of invalid args. This call should succeed.
try {
queue1.Pop( buffer, 50, length );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
if ( memcmp( buffer, data1, strlen(data1) ) != 0 ) {
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
/*
* Additional stuff to check while the Pop is uncommitted:
* - cannot get access to the item from first session.
* - can get access to the item from second session.
* - cannot modify it from second session.
*/
try {
//.........这里部分代码省略.........
示例14: main
int main( int argc, char * argv[] )
{
Process process;
Session session;
HashMap hashmap;
string fname = "/cpp_hashmap_getfirst";
string hname = fname + "/test";
const char * key = "My Key";
const char * data = "My Data";
char buffer[50];
char buffKey[50];
uint32_t dataLength, keyLength;
psoObjectDefinition mapDef = { PSO_HASH_MAP, 0, 0, 0 };
psoKeyFieldDefinition keyDef = { "MyKey", PSO_KEY_VARBINARY, 20 };
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_hashmap_getfirst",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)fields,
sizeof(psoFieldDefinition) );
KeyDefinition keyDefObj( session,
"cpp_hashmap_getfirst",
PSO_DEF_PHOTON_ODBC_SIMPLE,
(unsigned char *)&keyDef,
sizeof(psoKeyFieldDefinition) );
session.CreateMap( hname,
mapDef,
dataDefObj,
keyDefObj );
hashmap.Open( session, hname );
hashmap.Insert( key, 6, data, 7 );
}
catch( pso::Exception exc ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
// Invalid arguments to tested function.
try {
hashmap.GetFirst( NULL, 50, buffer, 50, keyLength, dataLength );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_POINTER ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
hashmap.GetFirst( buffKey, 2, buffer, 50, keyLength, dataLength );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_INVALID_LENGTH ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
try {
hashmap.GetFirst( buffKey, 50, NULL, 50, keyLength, dataLength );
// Should never come here
cerr << "Test failed - line " << __LINE__ << endl;
return 1;
}
catch( pso::Exception exc ) {
if ( exc.ErrorCode() != PSO_NULL_POINTER ) {
cerr << "Test failed - line " << __LINE__ << ", error = " << exc.Message() << endl;
return 1;
}
}
//.........这里部分代码省略.........
示例15: main
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;
}