@@ -360,15 +360,14 @@ void askUser(std::shared_ptr<ETP_NS::AbstractSession> session, COMMON_NS::DataOb
360360 else if (commandTokens[0 ] == " PutDataObject" ) {
361361 auto * dataObj = repo.getDataObjectByUuid (commandTokens[1 ]);
362362 if (dataObj != nullptr ) {
363- Energistics::Etp::v12::Protocol::Store::PutDataObjects putDataObjects;
364363 Energistics::Etp::v12::Datatypes::Object::DataObject dataObject = ETP_NS::FesapiHelpers::buildEtpDataObjectFromEnergisticsObject (dataObj);
365- putDataObjects. dataObjects [ " 0 " ] = dataObject ;
366-
367- session->send ( putDataObjects, 0 , 0x10 | 0x02 ); // 0x10 requires Acknowledge from the store
364+ std::map<std::string, Energistics::Etp::v12::Datatypes::Object::DataObject> dataObjects ;
365+ dataObjects[ " 0 " ] = dataObject;
366+ session->putDataObjects (dataObjects);
368367 }
369368 }
370369 else if (commandTokens[0 ] == " SubscribeNotif" ) {
371- Energistics::Etp::v12::Protocol::StoreNotification::SubscribeNotifications mb ;
370+ auto mb = std::make_shared< Energistics::Etp::v12::Protocol::StoreNotification::SubscribeNotifications>() ;
372371 Energistics::Etp::v12::Datatypes::Object::SubscriptionInfo subscriptionInfo;
373372 subscriptionInfo.context .uri = commandTokens[1 ];
374373 subscriptionInfo.scope = Energistics::Etp::v12::Datatypes::Object::ContextScopeKind::self;
@@ -402,7 +401,7 @@ void askUser(std::shared_ptr<ETP_NS::AbstractSession> session, COMMON_NS::DataOb
402401 }
403402 }
404403
405- mb. request [" 0" ] = subscriptionInfo;
404+ mb-> request [" 0" ] = subscriptionInfo;
406405
407406 session->send (mb, 0 , 0x02 );
408407
@@ -483,10 +482,10 @@ void askUser(std::shared_ptr<ETP_NS::AbstractSession> session, COMMON_NS::DataOb
483482 // session->deleteDataspaces({ {"0", "eml:///dataspace('project/study')"} });
484483 }
485484 else if (commandTokens[0 ] == " Ping" ) {
486- Energistics::Etp::v12::Protocol::Core::Ping ping ;
487- ping. currentDateTime = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ();
485+ auto ping = std::make_shared< Energistics::Etp::v12::Protocol::Core::Ping>() ;
486+ ping-> currentDateTime = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ();
488487 session->send (ping, 0 , 0x02 );
489- std::cout << " PING at " << ping. currentDateTime << std::endl;
488+ std::cout << " PING at " << ping-> currentDateTime << std::endl;
490489 std::cout << " Please Set Verbosity to 1 if you don't see anything" << std::endl;
491490 }
492491 else if (commandTokens[0 ] == " PutDummyHorizon" ) {
@@ -549,45 +548,49 @@ void askUser(std::shared_ptr<ETP_NS::AbstractSession> session, COMMON_NS::DataOb
549548
550549 auto transaction_start = std::chrono::high_resolution_clock::now ();
551550
552- session->startTransaction (dataspacesToLock);
553-
554- const size_t ni = 10000 ;
555- const size_t nj = 1000 ;
556- std::unique_ptr<double []> resqml_points (new double [ni * nj]);
557- for (double i = 0 ; i < ni * nj; ++i) {
558- resqml_points[(int )i] = i * 100 ;
559- }
560- horizon_grid_2d_representation->setGeometryAsArray2dOfExplicitZ (resqml_points.get (), ni, nj, hdf_proxy,
561- 0.0 , 0.0 , 0.0 ,
562- 1.0 , 0.0 , 0.0 , 25.0 ,
563- 0.0 , 1.0 , 0.0 , 50.0 );
564-
565- for (size_t propIndex = 0 ; propIndex < 1 ; ++propIndex) {
566- auto t_start = std::chrono::high_resolution_clock::now ();
567- auto * prop = tmpRepo.createContinuousProperty (horizon_grid_2d_representation, " " , " " , 1 , gsoap_eml2_3::eml23__IndexableElement::nodes, gsoap_resqml2_0_1::resqml20__ResqmlUom::m,
568- gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind::length);
569- std::unique_ptr<double []> prop_values (new double [ni * nj]);
570- prop->pushBackDoubleHdf5Array2dOfValues (prop_values.get (), ni, nj, hdf_proxy);
571- std::cout << " Pushed prop " << propIndex << " in " << std::chrono::duration<double , std::milli>(std::chrono::high_resolution_clock::now () - t_start).count () << " ms" << std::endl;
572- std::cout << " Global time " << std::chrono::duration<double >(std::chrono::high_resolution_clock::now () - transaction_start).count () << " s" << std::endl;
573- }
551+ std::string result = session->startTransaction (dataspacesToLock);
552+ if (result. empty ()) {
553+ const size_t ni = 10000 ;
554+ const size_t nj = 1000 ;
555+ std::unique_ptr<double []> resqml_points (new double [ni * nj]);
556+ for (double i = 0 ; i < ni * nj; ++i) {
557+ resqml_points[(int )i] = i * 100 ;
558+ }
559+ horizon_grid_2d_representation->setGeometryAsArray2dOfExplicitZ (resqml_points.get (), ni, nj, hdf_proxy,
560+ 0.0 , 0.0 , 0.0 ,
561+ 1.0 , 0.0 , 0.0 , 25.0 ,
562+ 0.0 , 1.0 , 0.0 , 50.0 );
563+
564+ for (size_t propIndex = 0 ; propIndex < 100 ; ++propIndex) {
565+ auto t_start = std::chrono::high_resolution_clock::now ();
566+ auto * prop = tmpRepo.createContinuousProperty (horizon_grid_2d_representation, " " , " " , 1 , gsoap_eml2_3::eml23__IndexableElement::nodes, gsoap_resqml2_0_1::resqml20__ResqmlUom::m,
567+ gsoap_resqml2_0_1::resqml20__ResqmlPropertyKind::length);
568+ std::unique_ptr<double []> prop_values (new double [ni * nj]);
569+ prop->pushBackDoubleHdf5Array2dOfValues (prop_values.get (), ni, nj, hdf_proxy);
570+ std::cout << " Pushed prop " << propIndex << " in " << std::chrono::duration<double , std::milli>(std::chrono::high_resolution_clock::now () - t_start).count () << " ms" << std::endl;
571+ std::cout << " Global time " << std::chrono::duration<double >(std::chrono::high_resolution_clock::now () - transaction_start).count () << " s" << std::endl;
572+ }
574573
575- tmpRepo.setUriSource (dataspace.uri );
576- std::map<std::string, Energistics::Etp::v12::Datatypes::Object::DataObject> dataobjects;
577- auto allUuids = tmpRepo.getUuids ();
578- int index = 0 ;
579- for (auto & uuid : allUuids)
580- dataobjects[std::to_string (index++)] = ETP_NS::FesapiHelpers::buildEtpDataObjectFromEnergisticsObject (tmpRepo, uuid);
581- successKeys = session->putDataObjects (dataobjects);
582- for (std::string& str : successKeys)
583- std::cout << " successKey : " << str << std::endl;
574+ tmpRepo.setUriSource (dataspace.uri );
575+ std::map<std::string, Energistics::Etp::v12::Datatypes::Object::DataObject> dataobjects;
576+ auto allUuids = tmpRepo.getUuids ();
577+ int index = 0 ;
578+ for (auto & uuid : allUuids)
579+ dataobjects[std::to_string (index++)] = ETP_NS::FesapiHelpers::buildEtpDataObjectFromEnergisticsObject (tmpRepo, uuid);
580+ successKeys = session->putDataObjects (dataobjects);
581+ for (std::string& str : successKeys)
582+ std::cout << " successKey : " << str << std::endl;
584583
585- std::cout << " commit : " << session->commitTransaction () << std::endl;
584+ std::cout << " commit : " << session->commitTransaction () << std::endl;
586585
587- if (session != nullptr && !session->isWebSocketSessionClosed ())
588- horizon_grid_2d_representation->getZValues (resqml_points.get ());
586+ if (session != nullptr && !session->isWebSocketSessionClosed ())
587+ horizon_grid_2d_representation->getZValues (resqml_points.get ());
589588
590- tmpRepo.clear ();
589+ tmpRepo.clear ();
590+ }
591+ else {
592+ std::cerr << " Error when opening transaction : " << result << std::endl;
593+ }
591594 }
592595 else if (commandTokens[0 ] == " GetDataspaces" ) {
593596 const auto dataspaces = session->getDataspaces ();
@@ -634,11 +637,10 @@ void askUser(std::shared_ptr<ETP_NS::AbstractSession> session, COMMON_NS::DataOb
634637 h1i1PointSetRep->pushBackXyzGeometryPatch (6 , pointCoords, nullptr , crs);
635638
636639 // Now send the XML part
637- Energistics::Etp::v12::Protocol::Store::PutDataObjects putDataObjects;
638640 Energistics::Etp::v12::Datatypes::Object::DataObject dataObject = ETP_NS::FesapiHelpers::buildEtpDataObjectFromEnergisticsObject (h1i1PointSetRep);
639- putDataObjects. dataObjects [ " 0 " ] = dataObject ;
640-
641- session->send ( putDataObjects, 0 , 0x02 | 0x10 ); // 0x10 requires Acknowledge from the store
641+ std::map<std::string, Energistics::Etp::v12::Datatypes::Object::DataObject> dataObjects ;
642+ dataObjects[ " 0 " ] = dataObject;
643+ session->putDataObjects (dataObjects);
642644 }
643645 else if (commandTokens[0 ] == " PutAllDataObjects" ) {
644646 std::map<std::string, Energistics::Etp::v12::Datatypes::Object::DataObject> putDataObjectsMap;
@@ -654,34 +656,34 @@ void askUser(std::shared_ptr<ETP_NS::AbstractSession> session, COMMON_NS::DataOb
654656 }
655657 else if (commandTokens.size () == 3 ) {
656658 if (commandTokens[0 ] == " GetDataArray" ) {
657- Energistics::Etp::v12::Protocol::DataArray::GetDataArrays gda ;
658- gda. dataArrays [" 0" ].uri = commandTokens[1 ];
659- gda. dataArrays [" 0" ].pathInResource = commandTokens[2 ];
660- std::cout << gda. dataArrays [" 0" ].pathInResource << std::endl;
659+ auto gda = std::make_shared< Energistics::Etp::v12::Protocol::DataArray::GetDataArrays>() ;
660+ gda-> dataArrays [" 0" ].uri = commandTokens[1 ];
661+ gda-> dataArrays [" 0" ].pathInResource = commandTokens[2 ];
662+ std::cout << gda-> dataArrays [" 0" ].pathInResource << std::endl;
661663 session->send (gda, 0 , 0x02 );
662664 std::cout << " Please Set Verbosity to 1 if you don't see anything" << std::endl;
663665 }
664666 else if (commandTokens[0 ] == " GetDataArrayMetadata" ) {
665- Energistics::Etp::v12::Protocol::DataArray::GetDataArrayMetadata msg ;
666- msg. dataArrays [" 0" ].uri = commandTokens[1 ];
667- msg. dataArrays [" 0" ].pathInResource = commandTokens[2 ];
668- std::cout << msg. dataArrays [" 0" ].pathInResource << std::endl;
667+ auto msg = std::make_shared< Energistics::Etp::v12::Protocol::DataArray::GetDataArrayMetadata>() ;
668+ msg-> dataArrays [" 0" ].uri = commandTokens[1 ];
669+ msg-> dataArrays [" 0" ].pathInResource = commandTokens[2 ];
670+ std::cout << msg-> dataArrays [" 0" ].pathInResource << std::endl;
669671 session->send (msg, 0 , 0x02 );
670672 std::cout << " Please Set Verbosity to 1 if you don't see anything" << std::endl;
671673 }
672674 else if (commandTokens[0 ] == " PutDataArray" ) {
673- Energistics::Etp::v12::Protocol::DataArray::PutDataArrays pda ;
674- pda. dataArrays [" 0" ].uid .uri = commandTokens[1 ];
675- pda. dataArrays [" 0" ].uid .pathInResource = commandTokens[2 ];
675+ auto pda = std::make_shared< Energistics::Etp::v12::Protocol::DataArray::PutDataArrays>() ;
676+ pda-> dataArrays [" 0" ].uid .uri = commandTokens[1 ];
677+ pda-> dataArrays [" 0" ].uid .pathInResource = commandTokens[2 ];
676678
677679 std::vector<int64_t > dimensions = { 10 };
678- pda. dataArrays [" 0" ].array .dimensions = dimensions;
680+ pda-> dataArrays [" 0" ].array .dimensions = dimensions;
679681
680682 Energistics::Etp::v12::Datatypes::AnyArray data;
681683 Energistics::Etp::v12::Datatypes::ArrayOfInt arrayOfInt;
682684 arrayOfInt.values = { 0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 };
683685 data.item .set_ArrayOfInt (std::move (arrayOfInt));
684- pda. dataArrays [" 0" ].array .data = data;
686+ pda-> dataArrays [" 0" ].array .data = data;
685687 std::cout << " Start sending the array" << std::endl;
686688
687689 session->send (pda, 0 , 0x02 );
@@ -751,12 +753,12 @@ int main(int argc, char **argv)
751753 auto t_start = std::chrono::high_resolution_clock::now ();
752754 while (clientSession->isEtpSessionClosed ()) {
753755 auto timeOut = std::chrono::duration<double , std::milli>(std::chrono::high_resolution_clock::now () - t_start).count ();
754- if (timeOut > 5000 ) {
756+ if (timeOut > 50000 ) {
755757 throw std::invalid_argument (" Time out : " + std::to_string (timeOut) + " ms.\n " );
756758 }
757759 }
758760
759- clientSession->setTimeOut (60000 );
761+ clientSession->setTimeOut (10000 );
760762 askUser (clientSession, repo);
761763
762764 sessionThread.join ();
0 commit comments