Skip to content

Commit

Permalink
sync triggers after configuration change
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Dec 11, 2015
1 parent 25a02c4 commit 96084ee
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions symmetric-client-clib/inc/io/writer/DataWriter.h
Expand Up @@ -38,6 +38,7 @@ typedef struct SymDataWriter {
void (*endTable)(struct SymDataWriter *this, SymTable *table);
void (*endBatch)(struct SymDataWriter *this, SymBatch *batch);
void (*destroy)(struct SymDataWriter *this);
unsigned short isSyncTriggersNeeded;
} SymDataWriter;

SymDataWriter * SymDataWriter_new(SymDataWriter *this);
Expand Down
2 changes: 1 addition & 1 deletion symmetric-client-clib/inc/model/Node.h
Expand Up @@ -23,7 +23,7 @@

#include <stdlib.h>

#define SYM_VERSION "3.7.27.1"
#define SYM_VERSION "3.7.27.2"

typedef enum SymNodeStatus {
SYM_NODE_STATUS_DATA_LOAD_NOT_STARTED,
Expand Down
4 changes: 3 additions & 1 deletion symmetric-client-clib/inc/service/DataLoaderService.h
Expand Up @@ -27,6 +27,7 @@
#include "service/NodeService.h"
#include "service/IncomingBatchService.h"
#include "service/ParameterService.h"
#include "service/TriggerRouterService.h"
#include "transport/TransportManager.h"
#include "transport/IncomingTransport.h"
#include "model/Node.h"
Expand All @@ -44,6 +45,7 @@
typedef struct SymDataLoaderService {
SymParameterService *parameterService;
SymNodeService *nodeService;
SymTriggerRouterService *triggerRouterService;
SymTransportManager *transportManager;
SymTransportManager *fileTransportManager;
SymDatabasePlatform *platform;
Expand All @@ -56,7 +58,7 @@ typedef struct SymDataLoaderService {
void (*destroy)(struct SymDataLoaderService *this);
} SymDataLoaderService;

SymDataLoaderService * SymDataLoaderService_new(SymDataLoaderService *this, SymParameterService *parameterService, SymNodeService *nodeService,
SymDataLoaderService * SymDataLoaderService_new(SymDataLoaderService *this, SymParameterService *parameterService, SymNodeService *nodeService, SymTriggerRouterService *triggerRouterService,
SymTransportManager *transportManager, SymTransportManager *fileTransportManager, SymDatabasePlatform *platform, SymDialect *dialect, SymIncomingBatchService *incomingBatchService);

#endif
4 changes: 2 additions & 2 deletions symmetric-client-clib/src/core/SymEngine.c
Expand Up @@ -186,8 +186,8 @@ SymEngine * SymEngine_new( SymEngine *this, SymProperties *properties) {
this->incomingBatchService = SymIncomingBatchService_new(NULL, this->platform, this->parameterService);
this->outgoingBatchService = SymOutgoingBatchService_new(NULL, this->platform, this->parameterService, this->sequenceService);
this->acknowledgeService = SymAcknowledgeService_new(NULL, this->outgoingBatchService, this->platform);
this->dataLoaderService = SymDataLoaderService_new(NULL, this->parameterService, this->nodeService, this->transportManager, this->offlineTransportManager,
this->platform, this->dialect, this->incomingBatchService);
this->dataLoaderService = SymDataLoaderService_new(NULL, this->parameterService, this->nodeService, this->triggerRouterService,
this->transportManager, this->offlineTransportManager, this->platform, this->dialect, this->incomingBatchService);
this->dataService = SymDataService_new(NULL, this->platform, this->triggerRouterService, this->nodeService, this->dialect, this->outgoingBatchService, this->parameterService);
this->routerService = SymRouterService_new(NULL, this->outgoingBatchService, this->sequenceService, this->dataService, this->nodeService, this->configurationService,
this->parameterService, this->triggerRouterService, this->platform);
Expand Down
14 changes: 13 additions & 1 deletion symmetric-client-clib/src/io/writer/DefaultDatabaseWriter.c
Expand Up @@ -207,6 +207,17 @@ unsigned short SymDefaultDatabaseWriter_write(SymDefaultDatabaseWriter *this, Sy
} else {
this->targetTable = this->sourceTable;
}
} else if (!this->super.isSyncTriggersNeeded) {
unsigned short autoSync = this->parameterService->is(this->parameterService, SYM_PARAMETER_AUTO_SYNC_CONFIGURATION, 1) ||
this->incomingBatch->batchId == SYM_VIRTUAL_BATCH_FOR_REGISTRATION;
if (autoSync && (SymStringUtils_equalsIgnoreCase(this->targetTable->name, SYM_TRIGGER) ||
SymStringUtils_equalsIgnoreCase(this->targetTable->name, SYM_ROUTER) ||
SymStringUtils_equalsIgnoreCase(this->targetTable->name, SYM_TRIGGER_ROUTER) ||
SymStringUtils_equalsIgnoreCase(this->targetTable->name, SYM_TRIGGER_ROUTER_GROUPLET) ||
SymStringUtils_equalsIgnoreCase(this->targetTable->name, SYM_GROUPLET_LINK) ||
SymStringUtils_equalsIgnoreCase(this->targetTable->name, SYM_NODE_GROUP_LINK))) {
this->super.isSyncTriggersNeeded = 1;
}
}
int error = 0;
switch (data->dataEventType) {
Expand Down Expand Up @@ -292,12 +303,13 @@ void SymDefaultDatabaseWriter_destroy(SymDefaultDatabaseWriter *this) {
}

SymDefaultDatabaseWriter * SymDefaultDatabaseWriter_new(SymDefaultDatabaseWriter *this, SymIncomingBatchService *incomingBatchService,
SymDatabasePlatform *platform, SymDialect *dialect, SymDatabaseWriterSettings *settings) {
SymParameterService *parameterService, SymDatabasePlatform *platform, SymDialect *dialect, SymDatabaseWriterSettings *settings) {
if (this == NULL) {
this = (SymDefaultDatabaseWriter *) calloc(1, sizeof(SymDefaultDatabaseWriter));
}
SymDataWriter *super = &this->super;
this->incomingBatchService = incomingBatchService;
this->parameterService = parameterService;
this->platform = platform;
this->dialect = dialect;
this->settings = settings;
Expand Down
3 changes: 2 additions & 1 deletion symmetric-client-clib/src/load/DefaultDataLoaderFactory.c
Expand Up @@ -29,7 +29,8 @@ static SymDatabaseWriterSettings * buildDatabaseWriterSettings(SymDefaultDataLoa

SymDataWriter * SymDefaultDataLoaderFactory_getDataWriter(SymDefaultDataLoaderFactory *this) {
SymDatabaseWriterSettings *settings = buildDatabaseWriterSettings(this);
SymDataWriter *writer = (SymDataWriter *) SymDefaultDatabaseWriter_new(NULL, this->incomingBatchService, this->platform, this->dialect, settings);
SymDataWriter *writer = (SymDataWriter *) SymDefaultDatabaseWriter_new(NULL, this->incomingBatchService, this->parameterService,
this->platform, this->dialect, settings);
return writer;
}

Expand Down
7 changes: 6 additions & 1 deletion symmetric-client-clib/src/service/DataLoaderService.c
Expand Up @@ -50,6 +50,10 @@ static SymList * SymDataLoaderService_loadDataFromTransport(SymDataLoaderService
SymLog_debug("Transport rc = %ld" , rc);

SymList *batchesProcessed = processor->getBatchesProcessed(processor);
if (writer->isSyncTriggersNeeded) {
this->triggerRouterService->syncTriggers(this->triggerRouterService, 0);
}

processor->destroy(processor);
writer->destroy(writer);
return batchesProcessed;
Expand Down Expand Up @@ -150,13 +154,14 @@ void SymDataLoaderService_destroy(SymDataLoaderService *this) {
free(this);
}

SymDataLoaderService * SymDataLoaderService_new(SymDataLoaderService *this, SymParameterService *parameterService, SymNodeService *nodeService,
SymDataLoaderService * SymDataLoaderService_new(SymDataLoaderService *this, SymParameterService *parameterService, SymNodeService *nodeService, SymTriggerRouterService *triggerRouterService,
SymTransportManager *transportManager, SymTransportManager *fileTransportManager, SymDatabasePlatform *platform, SymDialect *dialect, SymIncomingBatchService *incomingBatchService) {
if (this == NULL) {
this = (SymDataLoaderService *) calloc(1, sizeof(SymDataLoaderService));
}
this->parameterService = parameterService;
this->nodeService = nodeService;
this->triggerRouterService = triggerRouterService;
this->transportManager = transportManager;
this->fileTransportManager = fileTransportManager;
this->platform = platform;
Expand Down

0 comments on commit 96084ee

Please sign in to comment.