Skip to content

Commit

Permalink
Fixes for OfflinePush and OfflinePull.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmichalek committed Dec 10, 2015
1 parent 1b83a17 commit 8841095
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 41 deletions.
2 changes: 2 additions & 0 deletions symmetric-client-clib/inc/core/SymEngine.h
Expand Up @@ -35,6 +35,7 @@
#include "service/ParameterService.h"
#include "service/PushService.h"
#include "service/NodeService.h"
#include "service/NodeCommunicationService.h"
#include "service/PullService.h"
#include "service/RegistrationService.h"
#include "service/RouterService.h"
Expand Down Expand Up @@ -72,6 +73,7 @@ typedef struct SymEngine {
SymOfflinePushService *offlinePushService;
SymOfflinePullService *offlinePullService;
SymNodeService *nodeService;
SymNodeCommunicationService *nodeCommunicationService;
SymIncomingBatchService *incomingBatchService;
SymOutgoingBatchService *outgoingBatchService;
SymAcknowledgeService *acknowledgeService;
Expand Down
3 changes: 2 additions & 1 deletion symmetric-client-clib/inc/service/NodeCommunicationService.h
Expand Up @@ -37,6 +37,7 @@ typedef struct SymNodeCommunicationService {
void (*destroy)(struct SymNodeCommunicationService *this);
} SymNodeCommunicationService;

SymNodeCommunicationService * SymNodeCommunicationService_new(SymNodeCommunicationService *this, SymNodeService * nodeService);
SymNodeCommunicationService * SymNodeCommunicationService_new(SymNodeCommunicationService *this,
SymNodeService * nodeService, SymParameterService *parameterService);

#endif
7 changes: 5 additions & 2 deletions symmetric-client-clib/inc/service/OfflinePullService.h
Expand Up @@ -29,6 +29,7 @@
#include "service/DataLoaderService.h"
#include "service/RegistrationService.h"
#include "service/ConfigurationService.h"
#include "service/NodeCommunicationService.h"
#include "util/Map.h"
#include "common/Log.h"

Expand All @@ -37,12 +38,14 @@ typedef struct SymOfflinePullService {
SymDataLoaderService *dataLoaderService;
SymRegistrationService *registrationService;
SymConfigurationService *configurationService;
SymNodeCommunicationService *nodeCommunicationService;
SymRemoteNodeStatuses * (*pullData)(struct SymOfflinePullService *this);
void (*destroy)(struct SymOfflinePullService *this);
} SymOfflinePullService;

SymOfflinePullService * SymOfflinePullService_new(SymOfflinePullService *this, SymNodeService *nodeService, SymDataLoaderService *dataLoaderService,
SymRegistrationService *registrationService, SymConfigurationService *configurationService);
SymOfflinePullService * SymOfflinePullService_new(SymOfflinePullService *this, SymNodeService *nodeService,
SymDataLoaderService *dataLoaderService, SymRegistrationService *registrationService,
SymConfigurationService *configurationService, SymNodeCommunicationService *nodeCommunicationService);


#endif
10 changes: 6 additions & 4 deletions symmetric-client-clib/inc/service/OfflinePushService.h
Expand Up @@ -32,6 +32,7 @@
#include "service/ConfigurationService.h"
#include "service/DataExtractorService.h"
#include "service/AcknowledgeService.h"
#include "service/NodeCommunicationService.h"
#include "transport/TransportManager.h"
#include "transport/file/FileOutgoingTransport.h"
#include "util/List.h"
Expand All @@ -45,13 +46,14 @@ typedef struct SymOfflinePushService {
SymParameterService *parameterService;
SymConfigurationService *configurationService;
SymAcknowledgeService *acknowledgeService;
SymNodeCommunicationService *nodeCommunicationService;
SymRemoteNodeStatuses * (*pushData)(struct SymOfflinePushService *this);
void (*destroy)(struct SymOfflinePushService *);
} SymOfflinePushService;

SymOfflinePushService * SymOfflinePushService_new(SymOfflinePushService *this, SymNodeService *nodeService, SymDataExtractorService *dataExtractorService,
SymTransportManager *transportManager, SymParameterService *parameterService, SymConfigurationService *configurationService,
SymAcknowledgeService *acknowledgeService);

SymOfflinePushService * SymOfflinePushService_new(SymOfflinePushService *this, SymNodeService *nodeService,
SymDataExtractorService *dataExtractorService, SymTransportManager *transportManager,
SymParameterService *parameterService, SymConfigurationService *configurationService,
SymAcknowledgeService *acknowledgeService, SymNodeCommunicationService *nodeCommunicationService);

#endif
5 changes: 4 additions & 1 deletion symmetric-client-clib/inc/service/PullService.h
Expand Up @@ -29,6 +29,7 @@
#include "service/DataLoaderService.h"
#include "service/RegistrationService.h"
#include "service/ConfigurationService.h"
#include "service/NodeCommunicationService.h"
#include "util/Map.h"
#include "common/Log.h"

Expand All @@ -37,11 +38,13 @@ typedef struct SymPullService {
SymDataLoaderService *dataLoaderService;
SymRegistrationService *registrationService;
SymConfigurationService *configurationService;
SymNodeCommunicationService *nodeCommunicationService;
SymRemoteNodeStatuses * (*pullData)(struct SymPullService *this);
void (*destroy)(struct SymPullService *this);
} SymPullService;

SymPullService * SymPullService_new(SymPullService *this, SymNodeService *nodeService, SymDataLoaderService *dataLoaderService,
SymRegistrationService *registrationService, SymConfigurationService *configurationService);
SymRegistrationService *registrationService, SymConfigurationService *configurationService,
SymNodeCommunicationService *nodeCommunicationService);

#endif
4 changes: 3 additions & 1 deletion symmetric-client-clib/inc/service/PushService.h
Expand Up @@ -27,6 +27,7 @@
#include "model/RemoteNodeStatus.h"
#include "model/RemoteNodeStatuses.h"
#include "service/NodeService.h"
#include "service/NodeCommunicationService.h"
#include "service/ParameterService.h"
#include "service/ConfigurationService.h"
#include "service/DataExtractorService.h"
Expand All @@ -37,6 +38,7 @@
#include "common/Log.h"

typedef struct SymPushService {
SymNodeCommunicationService *nodeCommunicationService;
SymNodeService *nodeService;
SymDataExtractorService *dataExtractorService;
SymTransportManager *transportManager;
Expand All @@ -49,6 +51,6 @@ typedef struct SymPushService {

SymPushService * SymPushService_new(SymPushService *this, SymNodeService *nodeService, SymDataExtractorService *dataExtractorService,
SymTransportManager *transportManager, SymParameterService *parameterService, SymConfigurationService *configurationService,
SymAcknowledgeService *acknowledgeService);
SymAcknowledgeService *acknowledgeService, SymNodeCommunicationService *nodeCommunicationService);

#endif
Expand Up @@ -23,6 +23,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <curl/curl.h>
#include <util/Properties.h>
#include <dirent.h>
Expand Down
Expand Up @@ -22,6 +22,7 @@
#define SYM_FILEOUTGOINGTRANSPORT_H

#include <stdlib.h>
#include <errno.h>
#include "common/Log.h"
#include "model/Node.h"
#include "service/ParameterService.h"
Expand Down
32 changes: 32 additions & 0 deletions symmetric-client-clib/inc/util/FileUtils.h
@@ -0,0 +1,32 @@
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef SYM_FILEUTILS_H
#define SYM_FILEUTILS_H

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "common/Log.h"

int SymFileUtils_mkdir(char* dirName);

#endif
14 changes: 9 additions & 5 deletions symmetric-client-clib/src/core/SymEngine.c
Expand Up @@ -182,6 +182,7 @@ SymEngine * SymEngine_new( SymEngine *this, SymProperties *properties) {
this->offlineTransportManager = SymTransportManagerFactory_create(SYM_PROTOCOL_FILE, this->parameterService);
this->nodeService = SymNodeService_new(NULL, this->platform);
this->nodeService->lastRestartTime = SymDate_new(NULL);
this->nodeCommunicationService = SymNodeCommunicationService_new(NULL, this->nodeService, this->parameterService);
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);
Expand All @@ -194,12 +195,15 @@ SymEngine * SymEngine_new( SymEngine *this, SymProperties *properties) {
this->triggerRouterService, this->parameterService, this->platform);
this->registrationService = SymRegistrationService_new(NULL, this->nodeService, this->dataLoaderService, this->parameterService,
this->configurationService);
this->pullService = SymPullService_new(NULL, this->nodeService, this->dataLoaderService, this->registrationService, this->configurationService);
this->pullService = SymPullService_new(NULL, this->nodeService, this->dataLoaderService, this->registrationService,
this->configurationService, this->nodeCommunicationService);
this->pushService = SymPushService_new(NULL, this->nodeService, this->dataExtractorService, this->transportManager, this->parameterService,
this->configurationService, this->acknowledgeService);
this->offlinePullService = SymOfflinePullService_new(NULL, this->nodeService, this->dataLoaderService, this->registrationService, this->configurationService);
this->offlinePushService = SymOfflinePushService_new(NULL, this->nodeService, this->dataExtractorService, this->offlineTransportManager, this->parameterService,
this->configurationService, this->acknowledgeService);
this->configurationService, this->acknowledgeService, this->nodeCommunicationService);
this->offlinePullService = SymOfflinePullService_new(NULL, this->nodeService,
this->dataLoaderService, this->registrationService, this->configurationService, this->nodeCommunicationService);
this->offlinePushService = SymOfflinePushService_new(NULL, this->nodeService,
this->dataExtractorService, this->offlineTransportManager, this->parameterService,
this->configurationService, this->acknowledgeService, this->nodeCommunicationService);
this->purgeService = SymPurgeService_new(NULL, this->parameterService, this->dialect, this->platform);

return this;
Expand Down
8 changes: 5 additions & 3 deletions symmetric-client-clib/src/service/NodeCommunicationService.c
Expand Up @@ -108,10 +108,10 @@ SymList * SymNodeCommunicationService_list(SymNodeCommunicationService *this, Sy
nodesToCommunicateWith = SymNodeCommunicationService_removeOfflineNodes(this, this->nodeService->findNodesToPushTo(this->nodeService));
break;
case SYM_COMMUNICATION_TYPE_OFFLN_PUSH:
nodesToCommunicateWith = SymNodeCommunicationService_getNodesToCommunicateWithOffline(this, SYM_COMMUNICATION_TYPE_FILE_PUSH);
nodesToCommunicateWith = SymNodeCommunicationService_getNodesToCommunicateWithOffline(this, SYM_COMMUNICATION_TYPE_PUSH);
break;
case SYM_COMMUNICATION_TYPE_OFFLN_PULL:
nodesToCommunicateWith = SymNodeCommunicationService_getNodesToCommunicateWithOffline(this, SYM_COMMUNICATION_TYPE_FILE_PULL);
nodesToCommunicateWith = SymNodeCommunicationService_getNodesToCommunicateWithOffline(this, SYM_COMMUNICATION_TYPE_PULL);
break;
default:
nodesToCommunicateWith = SymList_new(NULL);
Expand All @@ -125,11 +125,13 @@ void SymNodeCommunicationService_destroy(SymNodeCommunicationService *this) {
free(this);
}

SymNodeCommunicationService * SymNodeCommunicationService_new(SymNodeCommunicationService *this, SymNodeService * nodeService) {
SymNodeCommunicationService * SymNodeCommunicationService_new(SymNodeCommunicationService *this,
SymNodeService * nodeService, SymParameterService *parameterService) {
if (this == NULL) {
this = (SymNodeCommunicationService *) calloc(1, sizeof(SymNodeCommunicationService));
}
this->nodeService = nodeService;
this->parameterService = parameterService;
this->list = (void *) &SymNodeCommunicationService_list;
this->destroy = (void *) &SymNodeCommunicationService_destroy;
return this;
Expand Down
8 changes: 5 additions & 3 deletions symmetric-client-clib/src/service/OfflinePullService.c
Expand Up @@ -48,7 +48,7 @@ SymRemoteNodeStatuses * SymOfflinePullService_pullData(SymOfflinePullService *th
identity = this->nodeService->findIdentity(this->nodeService);
}
if (identity->syncEnabled) {
SymList *nodes = this->nodeService->findNodesToPull(this->nodeService);
SymList *nodes = this->nodeCommunicationService->list(this->nodeCommunicationService, SYM_COMMUNICATION_TYPE_OFFLN_PULL);
SymMap *channels = this->configurationService->getChannels(this->configurationService, 0);
statuses = SymRemoteNodeStatuses_new(NULL, channels);
SymIterator *iter = nodes->iterator(nodes);
Expand All @@ -68,15 +68,17 @@ void SymOfflinePullService_destroy(SymOfflinePullService *this) {
free(this);
}

SymOfflinePullService * SymOfflinePullService_new(SymOfflinePullService *this, SymNodeService *nodeService, SymDataLoaderService *dataLoaderService,
SymRegistrationService *registrationService, SymConfigurationService *configurationService) {
SymOfflinePullService * SymOfflinePullService_new(SymOfflinePullService *this, SymNodeService *nodeService,
SymDataLoaderService *dataLoaderService, SymRegistrationService *registrationService,
SymConfigurationService *configurationService, SymNodeCommunicationService *nodeCommunicationService) {
if (this == NULL) {
this = (SymOfflinePullService *) calloc(1, sizeof(SymOfflinePullService));
}
this->nodeService = nodeService;
this->dataLoaderService = dataLoaderService;
this->registrationService = registrationService;
this->configurationService = configurationService;
this->nodeCommunicationService = nodeCommunicationService;
this->pullData = (void *) &SymOfflinePullService_pullData;
this->destroy = (void *) &SymOfflinePullService_destroy;
return this;
Expand Down
10 changes: 6 additions & 4 deletions symmetric-client-clib/src/service/OfflinePushService.c
Expand Up @@ -107,7 +107,7 @@ SymRemoteNodeStatuses * SymOfflinePushService_pushData(SymOfflinePushService *th
SymRemoteNodeStatuses *statuses = SymRemoteNodeStatuses_new(NULL, channels);
SymNode *identity = this->nodeService->findIdentity(this->nodeService);
if (identity && identity->syncEnabled) {
SymList *nodes = this->nodeService->findNodesToPushTo(this->nodeService);
SymList *nodes = this->nodeCommunicationService->list(this->nodeCommunicationService, SYM_COMMUNICATION_TYPE_OFFLN_PUSH);
if (nodes->size > 0) {
SymNodeSecurity *identitySecurity = this->nodeService->findNodeSecurity(this->nodeService, identity->nodeId);
if (identitySecurity) {
Expand All @@ -134,9 +134,10 @@ void SymOfflinePushService_destroy(SymOfflinePushService *this) {
free(this);
}

SymOfflinePushService * SymOfflinePushService_new(SymOfflinePushService *this, SymNodeService *nodeService, SymDataExtractorService *dataExtractorService,
SymTransportManager *transportManager, SymParameterService *parameterService, SymConfigurationService *configurationService,
SymAcknowledgeService *acknowledgeService) {
SymOfflinePushService * SymOfflinePushService_new(SymOfflinePushService *this, SymNodeService *nodeService,
SymDataExtractorService *dataExtractorService, SymTransportManager *transportManager,
SymParameterService *parameterService, SymConfigurationService *configurationService,
SymAcknowledgeService *acknowledgeService, SymNodeCommunicationService *nodeCommunicationService) {
if (this == NULL) {
this = (SymOfflinePushService *) calloc(1, sizeof(SymOfflinePushService));
}
Expand All @@ -146,6 +147,7 @@ SymOfflinePushService * SymOfflinePushService_new(SymOfflinePushService *this, S
this->parameterService = parameterService;
this->configurationService = configurationService;
this->acknowledgeService = acknowledgeService;
this->nodeCommunicationService = nodeCommunicationService;
this->pushData = (void *) &SymOfflinePushService_pushData;
this->destroy = (void *) &SymOfflinePushService_destroy;
return this;
Expand Down
6 changes: 4 additions & 2 deletions symmetric-client-clib/src/service/PullService.c
Expand Up @@ -53,7 +53,7 @@ SymRemoteNodeStatuses * SymPullService_pullData(SymPullService *this) {
identity = this->nodeService->findIdentity(this->nodeService);
}
if (identity->syncEnabled) {
SymList *nodes = this->nodeService->findNodesToPull(this->nodeService);
SymList *nodes = this->nodeCommunicationService->list(this->nodeCommunicationService, SYM_COMMUNICATION_TYPE_PULL);
SymMap *channels = this->configurationService->getChannels(this->configurationService, 0);
statuses = SymRemoteNodeStatuses_new(NULL, channels);
SymIterator *iter = nodes->iterator(nodes);
Expand All @@ -74,14 +74,16 @@ void SymPullService_destroy(SymPullService *this) {
}

SymPullService * SymPullService_new(SymPullService *this, SymNodeService *nodeService, SymDataLoaderService *dataLoaderService,
SymRegistrationService *registrationService, SymConfigurationService *configurationService) {
SymRegistrationService *registrationService, SymConfigurationService *configurationService,
SymNodeCommunicationService *nodeCommunicationService) {
if (this == NULL) {
this = (SymPullService *) calloc(1, sizeof(SymPullService));
}
this->nodeService = nodeService;
this->dataLoaderService = dataLoaderService;
this->registrationService = registrationService;
this->configurationService = configurationService;
this->nodeCommunicationService = nodeCommunicationService;
this->pullData = (void *) &SymPullService_pullData;
this->destroy = (void *) &SymPullService_destroy;
return this;
Expand Down
5 changes: 3 additions & 2 deletions symmetric-client-clib/src/service/PushService.c
Expand Up @@ -107,7 +107,7 @@ SymRemoteNodeStatuses * SymPushService_pushData(SymPushService *this, unsigned i
SymRemoteNodeStatuses *statuses = SymRemoteNodeStatuses_new(NULL, channels);
SymNode *identity = this->nodeService->findIdentity(this->nodeService);
if (identity && identity->syncEnabled) {
SymList *nodes = this->nodeService->findNodesToPushTo(this->nodeService);
SymList *nodes = this->nodeCommunicationService->list(this->nodeCommunicationService, SYM_COMMUNICATION_TYPE_PUSH);
if (nodes->size > 0) {
SymNodeSecurity *identitySecurity = this->nodeService->findNodeSecurity(this->nodeService, identity->nodeId);
if (identitySecurity) {
Expand Down Expand Up @@ -136,7 +136,7 @@ void SymPushService_destroy(SymPushService *this) {

SymPushService * SymPushService_new(SymPushService *this, SymNodeService *nodeService, SymDataExtractorService *dataExtractorService,
SymTransportManager *transportManager, SymParameterService *parameterService, SymConfigurationService *configurationService,
SymAcknowledgeService *acknowledgeService) {
SymAcknowledgeService *acknowledgeService, SymNodeCommunicationService *nodeCommunicationService) {
if (this == NULL) {
this = (SymPushService *) calloc(1, sizeof(SymPushService));
}
Expand All @@ -146,6 +146,7 @@ SymPushService * SymPushService_new(SymPushService *this, SymNodeService *nodeSe
this->parameterService = parameterService;
this->configurationService = configurationService;
this->acknowledgeService = acknowledgeService;
this->nodeCommunicationService = nodeCommunicationService;
this->pushData = (void *) &SymPushService_pushData;
this->destroy = (void *) &SymPushService_destroy;
return this;
Expand Down

0 comments on commit 8841095

Please sign in to comment.