View Issue Details

IDProjectCategoryView StatusLast Update
0001441SymmetricDSNew Featurepublic2014-06-16 20:27
ReporternswendalAssigned Tochenson 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version3.5.9 
Target Version3.6.0Fixed in Version3.6.0 
Summary0001441: Add ability to sync on control file
DescriptionCreate a new flag in the SYM_FILE_TRIGGER table called SYNC_ON_CTL_FILE. When checked, The FileTriggerTracker will verify that a control file exists for the file prior to adding it to the snapshot.
TagsNo tags attached.

Activities

nswendal

2013-10-14 12:03

reporter  

0001441_sync_on_ctl_file.patch (17,760 bytes)
### Eclipse Workspace Patch 1.0
#P symmetric-core
Index: src/main/java/org/jumpmind/symmetric/model/FileTrigger.java
===================================================================
--- src/main/java/org/jumpmind/symmetric/model/FileTrigger.java	(revision 7716)
+++ src/main/java/org/jumpmind/symmetric/model/FileTrigger.java	(working copy)
@@ -46,6 +46,7 @@
     private boolean syncOnCreate = true;
     private boolean syncOnModified = true;
     private boolean syncOnDelete = true;
+    private boolean syncOnCtlFile = false;
     private String beforeCopyScript;
     private String afterCopyScript;
     private Date createTime = new Date();
@@ -128,6 +129,14 @@
         this.syncOnDelete = syncOnDelete;
     }
 
+    public boolean isSyncOnCtlFile() {
+        return syncOnCtlFile;
+    }
+
+    public void setSyncOnCtlFile(boolean syncOnCtlFile) {
+        this.syncOnCtlFile = syncOnCtlFile;
+    }
+    
     public Date getCreateTime() {
         return createTime;
     }
Index: src/main/java/org/jumpmind/symmetric/service/impl/FileSyncServiceSqlMap.java
===================================================================
--- src/main/java/org/jumpmind/symmetric/service/impl/FileSyncServiceSqlMap.java	(revision 7716)
+++ src/main/java/org/jumpmind/symmetric/service/impl/FileSyncServiceSqlMap.java	(working copy)
@@ -32,12 +32,13 @@
         // @formatter:off
 
         putSql("selectFileTriggersSql",
-                " select trigger_id, base_dir, recurse,                                     " +
+                " select trigger_id, base_dir, recurse,                                       " +
                 "        includes_files, excludes_files,                                      " +
         		"        sync_on_create, sync_on_modified, sync_on_delete,                    " +
+        		"        sync_on_ctl_file,                                                    " +
                 "        before_copy_script,                                                  " +
                 "        after_copy_script,                                                   " +
-        		"        create_time, last_update_by,                                          " +
+        		"        create_time, last_update_by,                                         " +
         		"        last_update_time                                                     " +
         		" from $(file_trigger)                                                        ");
 
@@ -46,16 +47,18 @@
 
         putSql("updateFileTriggerSql",
                 " update $(file_trigger) set base_dir=?, recurse=?, includes_files=?,         " +
-        		"  excludes_files=?, sync_on_create=?, sync_on_modified=?, sync_on_delete=?,    " +
-                "  before_copy_script=?, after_copy_script=?,                                   " +
-        		"  last_update_by=?, last_update_time=? where trigger_id=?                      ");
+        		"  excludes_files=?, sync_on_create=?, sync_on_modified=?, sync_on_delete=?,  " +
+        		"  sync_on_ctl_file=?,                                                        " +
+                "  before_copy_script=?, after_copy_script=?,                                 " +
+        		"  last_update_by=?, last_update_time=? where trigger_id=?                    ");
 
         putSql("insertFileTriggerSql",
                 " insert into $(file_trigger) (base_dir, recurse, includes_files,             " +
-                "  excludes_files, sync_on_create, sync_on_modified, sync_on_delete,            " +
-                "  before_copy_script, after_copy_script,                                       " +
-                "  last_update_by, last_update_time, trigger_id, create_time)                   " +
-                " values(?,?,?,?,?,?,?,?,?,?,?,?,?)                                             ");
+                "  excludes_files, sync_on_create, sync_on_modified, sync_on_delete,          " +
+                "  sync_on_ctl_file,                                                          " +
+                "  before_copy_script, after_copy_script,                                     " +
+                "  last_update_by, last_update_time, trigger_id, create_time)                 " +
+                " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)                                         ");
 
         putSql("selectFileSnapshotSql",
                 " select trigger_id, router_id, relative_dir, file_name, last_event_type, crc32_checksum, " +
Index: src/main/java/org/jumpmind/symmetric/service/impl/FileSyncService.java
===================================================================
--- src/main/java/org/jumpmind/symmetric/service/impl/FileSyncService.java	(revision 7716)
+++ src/main/java/org/jumpmind/symmetric/service/impl/FileSyncService.java	(working copy)
@@ -182,7 +182,9 @@
                         fileTrigger.getIncludesFiles(), fileTrigger.getExcludesFiles(),
                         fileTrigger.isSyncOnCreate() ? 1 : 0,
                         fileTrigger.isSyncOnModified() ? 1 : 0,
-                        fileTrigger.isSyncOnDelete() ? 1 : 0, fileTrigger.getBeforeCopyScript(),
+                        fileTrigger.isSyncOnDelete() ? 1 : 0, 
+                        fileTrigger.isSyncOnCtlFile() ? 1 : 0,
+                        fileTrigger.getBeforeCopyScript(),
                         fileTrigger.getAfterCopyScript(), fileTrigger.getLastUpdateBy(),
                         fileTrigger.getLastUpdateTime(), fileTrigger.getTriggerId() }, new int[] {
                         Types.VARCHAR, Types.SMALLINT, Types.VARCHAR, Types.VARCHAR,
@@ -195,6 +197,7 @@
                             fileTrigger.isSyncOnCreate() ? 1 : 0,
                             fileTrigger.isSyncOnModified() ? 1 : 0,
                             fileTrigger.isSyncOnDelete() ? 1 : 0,
+                            fileTrigger.isSyncOnCtlFile() ? 1 : 0,
                             fileTrigger.getBeforeCopyScript(), fileTrigger.getAfterCopyScript(),
                             fileTrigger.getLastUpdateBy(), fileTrigger.getLastUpdateTime(),
                             fileTrigger.getTriggerId(), fileTrigger.getCreateTime() }, new int[] {
@@ -721,6 +724,7 @@
             fileTrigger.setAfterCopyScript(rs.getString("after_copy_script"));
             fileTrigger.setBeforeCopyScript(rs.getString("before_copy_script"));
             fileTrigger.setSyncOnModified(rs.getBoolean("sync_on_modified"));
+            fileTrigger.setSyncOnCtlFile(rs.getBoolean("sync_on_ctl_file"));
             fileTrigger.setTriggerId(rs.getString("trigger_id"));
             return fileTrigger;
         }
Index: src/main/resources/symmetric-schema.xml
===================================================================
--- src/main/resources/symmetric-schema.xml	(revision 7716)
+++ src/main/resources/symmetric-schema.xml	(working copy)
@@ -696,6 +696,7 @@
         <column name="sync_on_create" type="BOOLEANINT" size="1" required="true" default="1"  description="Whether to capture and send files when they are created." />
         <column name="sync_on_modified" type="BOOLEANINT" size="1" required="true" default="1"  description="Whether to capture and send files when they are modified." />
         <column name="sync_on_delete" type="BOOLEANINT" size="1" required="true" default="1"  description="Whether to capture and remove files when they are deleted." />
+        <column name="sync_on_ctl_file" type="BOOLEANINT" size="1" required="true" default="1"  description="Combined with sync_on_create, determines whether to capture and send files when a matching control file exists." />
         <column name="before_copy_script" type="LONGVARCHAR" description="A bsh script that is run right before the file copy." />
         <column name="after_copy_script" type="LONGVARCHAR" description="A bsh script that is run right after the file copy." />
         <column name="create_time" type="TIMESTAMP" required="true"  description="Timestamp of when this entry was created." />
Index: src/main/java/org/jumpmind/symmetric/file/FileTriggerTracker.java
===================================================================
--- src/main/java/org/jumpmind/symmetric/file/FileTriggerTracker.java	(revision 7716)
+++ src/main/java/org/jumpmind/symmetric/file/FileTriggerTracker.java	(working copy)
@@ -115,12 +115,27 @@
         }
 
         public void onFileCreate(File file) {
-            if (populateAll || snapshot.getFileTriggerRouter().getFileTrigger().isSyncOnCreate()) {
-                log.debug("File create detected: {}", file.getAbsolutePath());
-                this.snapshot.add(new FileSnapshot(snapshot.getFileTriggerRouter(), file,
-                        LastEventType.CREATE));
+            if (snapshot.getFileTriggerRouter().getFileTrigger().isSyncOnCtlFile()){
+                onCtlFile(file);
+            } else {
+                if (populateAll || snapshot.getFileTriggerRouter().getFileTrigger().isSyncOnCreate()) {
+                    log.debug("File create detected: {}", file.getAbsolutePath());
+                    this.snapshot.add(new FileSnapshot(snapshot.getFileTriggerRouter(), file,
+                            LastEventType.CREATE));
+                }
             }
         }
+        
+        public void onCtlFile(File file) {
+          if (snapshot.getFileTriggerRouter().getFileTrigger().isSyncOnCtlFile()){
+              File ctlFile = new File(file.getAbsolutePath() + ".ctl");
+              if (ctlFile.exists()) {
+                  log.debug("Control file detected: {}", file.getAbsolutePath());
+                  this.snapshot.add(new FileSnapshot(snapshot.getFileTriggerRouter(), file,
+                          LastEventType.CREATE));
+              }
+          }
+      }
 
         public void onFileChange(File file) {
             if (populateAll || snapshot.getFileTriggerRouter().getFileTrigger().isSyncOnModified()) {
#P symmetric-server
Index: src/test/resources/org/jumpmind/symmetric/test/WildcardTest.csv
===================================================================
--- src/test/resources/org/jumpmind/symmetric/test/WildcardTest.csv	(revision 7714)
+++ src/test/resources/org/jumpmind/symmetric/test/WildcardTest.csv	(working copy)
@@ -12,7 +12,7 @@
 schema,
 table,SYM_FILE_TRIGGER
 keys,TRIGGER_ID
-columns,TRIGGER_ID,BASE_DIR,RECURSIVE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
+columns,TRIGGER_ID,BASE_DIR,RECURSIVE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,SYNC_ON_CTL_FILE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
 sql,delete from sym_file_trigger
 catalog,
 schema,
Index: src/test/resources/org/jumpmind/symmetric/test/RestServiceTest.csv
===================================================================
--- src/test/resources/org/jumpmind/symmetric/test/RestServiceTest.csv	(revision 7714)
+++ src/test/resources/org/jumpmind/symmetric/test/RestServiceTest.csv	(working copy)
@@ -12,7 +12,7 @@
 schema,
 table,SYM_FILE_TRIGGER
 keys,TRIGGER_ID
-columns,TRIGGER_ID,BASE_DIR,RECURSE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
+columns,TRIGGER_ID,BASE_DIR,RECURSE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,SYNC_ON_CTL_FILE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
 sql,delete from sym_file_trigger
 catalog,
 schema,
Index: src/test/resources/org/jumpmind/symmetric/test/FileSyncTest.csv
===================================================================
--- src/test/resources/org/jumpmind/symmetric/test/FileSyncTest.csv	(revision 7714)
+++ src/test/resources/org/jumpmind/symmetric/test/FileSyncTest.csv	(working copy)
@@ -12,7 +12,7 @@
 schema,
 table,SYM_FILE_TRIGGER
 keys,TRIGGER_ID
-columns,TRIGGER_ID,BASE_DIR,RECURSE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
+columns,TRIGGER_ID,BASE_DIR,RECURSE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,SYNC_ON_CTL_FILE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
 sql,delete from sym_file_trigger
 catalog,
 schema,
@@ -127,11 +127,11 @@
 catalog,
 schema,
 table,SYM_FILE_TRIGGER
-insert,"all","target/fs_svr/all","1",,,"1","1","1",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
-insert,"create_only","target/fs_svr/create_only","1",,,"1","0","0",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
-insert,"all_recursive","target/fs_svr/all_recursive","1",,,"1","1","1",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
-insert,"csv_only","target/fs_svr/csv_only","1","*.txt",,"1","1","1",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
-insert,"choose_target","target/fs_svr/choose_target","1",,,"1","1","1","
+insert,"all","target/fs_svr/all","1",,,"1","1","1","0",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
+insert,"create_only","target/fs_svr/create_only","1",,,"1","0","0","0",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
+insert,"all_recursive","target/fs_svr/all_recursive","1",,,"1","1","1","0",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
+insert,"csv_only","target/fs_svr/csv_only","1","*.txt",,"1","1","1","0",,,"2013-05-19 10:13:26.966","unit_test","2013-05-19 10:13:26.966"
+insert,"choose_target","target/fs_svr/choose_target","1",,,"1","1","1","0","
 a = new java.io.File(\"target/fs_clnt/choose_target/a\");
 b = new java.io.File(\"target/fs_clnt/choose_target/b\");
 if (org.apache.commons.io.FileUtils.sizeOfDirectory(a) > org.apache.commons.io.FileUtils.sizeOfDirectory(b)) {
@@ -140,10 +140,10 @@
    targetBaseDir = a.getAbsolutePath();
 }
 ",,"2013-05-19 10:14:04.830","unit_test","2013-05-19 10:14:04.830"
-insert,"client_src","target/fs_clnt/client_src","1",,,"1","1","1",,,"2013-05-19 13:56:18.456","unit_test","2013-05-19 13:56:18.456"
-insert,"ping_back_clnt","target/fs_clnt/ping_back","1",,,"1","1","1",,,"2013-05-19 13:58:24.779","unit_test","2013-05-19 13:58:24.779"
-insert,"ping_back_svr","target/fs_svr/ping_back","1",,,"1","1","1",,,"2013-05-19 13:59:05.366","unit_test","2013-05-19 13:59:05.366"
-insert,"test_change_filename","target/fs_svr/change_name","0","source.txt",,"1","1","1","targetFileName = \"target.txt\";",,"2013-07-11 14:25:27.690","admin","2013-07-11 14:25:27.690"
+insert,"client_src","target/fs_clnt/client_src","1",,,"1","1","1","0",,,"2013-05-19 13:56:18.456","unit_test","2013-05-19 13:56:18.456"
+insert,"ping_back_clnt","target/fs_clnt/ping_back","1",,,"1","1","1","0",,,"2013-05-19 13:58:24.779","unit_test","2013-05-19 13:58:24.779"
+insert,"ping_back_svr","target/fs_svr/ping_back","1",,,"1","1","1","0",,,"2013-05-19 13:59:05.366","unit_test","2013-05-19 13:59:05.366"
+insert,"test_change_filename","target/fs_svr/change_name","0","source.txt",,"1","1","1","0","targetFileName = \"target.txt\";",,"2013-07-11 14:25:27.690","admin","2013-07-11 14:25:27.690"
 catalog,
 schema,
 table,SYM_FILE_TRIGGER_ROUTER
Index: src/test/resources/org/jumpmind/symmetric/test/NonDmlEventsTest.csv
===================================================================
--- src/test/resources/org/jumpmind/symmetric/test/NonDmlEventsTest.csv	(revision 7714)
+++ src/test/resources/org/jumpmind/symmetric/test/NonDmlEventsTest.csv	(working copy)
@@ -12,7 +12,7 @@
 schema,
 table,SYM_FILE_TRIGGER
 keys,TRIGGER_ID
-columns,TRIGGER_ID,BASE_DIR,RECURSE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
+columns,TRIGGER_ID,BASE_DIR,RECURSE,INCLUDES_FILES,EXCLUDES_FILES,SYNC_ON_CREATE,SYNC_ON_MODIFIED,SYNC_ON_DELETE,SYNC_ON_CTL_FILE,BEFORE_COPY_SCRIPT,AFTER_COPY_SCRIPT,CREATE_TIME,LAST_UPDATE_BY,LAST_UPDATE_TIME
 sql,delete from sym_file_trigger
 catalog,
 schema,
#P symmetric-assemble
Index: src/docbook/file-sync.xml
===================================================================
--- src/docbook/file-sync.xml	(revision 7714)
+++ src/docbook/file-sync.xml	(working copy)
@@ -228,9 +228,9 @@
 
 <programlisting>INSERT INTO sym_file_trigger
   (trigger_id,base_dir,recurse,includes_files,excludes_files,sync_on_create,
-   sync_on_modified,sync_on_delete,before_copy_script,after_copy_script,
+   sync_on_modified,sync_on_delete,sync_on_ctl_file,before_copy_script,after_copy_script,
    create_time,last_update_by,last_update_time)
-VALUES ('sync_directory','/filesync/server/all',1,'*.txt',null,1,1,1,
+VALUES ('sync_directory','/filesync/server/all',1,'*.txt',null,1,1,1,0,
   'targetBaseDir = "/filesync/clients/" +
   engine.getParameterService().getExternalId();',null,current_timestamp,'example',
   current_timestamp);
@@ -272,10 +272,10 @@
 <![CDATA[
 INSERT INTO sym_file_trigger
   (trigger_id,base_dir,recurse,includes_files,excludes_files,sync_on_create,
-  sync_on_modified,sync_on_delete,before_copy_script,after_copy_script,create_time,
+  sync_on_modified,sync_on_delete,sync_on_ctl_file,before_copy_script,after_copy_script,create_time,
   last_update_by,last_update_time)
 VALUES
-  ('node_specific','/filesync/server/nodes',1,null,null,1,1,1,'',null,
+  ('node_specific','/filesync/server/nodes',1,null,null,1,1,1,0,'',null,
   current_timestamp,'example',current_timestamp);
 
 INSERT INTO sym_file_trigger_router

Issue History

Date Modified Username Field Change
2013-10-14 10:48 nswendal New Issue
2013-10-14 12:03 nswendal File Added: 0001441_sync_on_ctl_file.patch
2013-11-05 08:04 chenson Target Version => 3.6.0
2014-02-17 20:36 chenson Assigned To => chenson
2014-02-17 20:36 chenson Status new => assigned
2014-02-17 21:12 chenson Status assigned => resolved
2014-02-17 21:12 chenson Fixed in Version => 3.6.0
2014-02-17 21:12 chenson Resolution open => fixed
2014-06-16 20:27 chenson Status resolved => closed