Hi,

I have update the log messages and methods mentioned earlier. Find the
attached patch.

Thanks,
Nipuni


On Wed, Jul 9, 2014 at 3:35 PM, Nipuni Perera <[email protected]> wrote:

>
> Hi,
>
> I am working on $subject.Three methods below
>
>    1.
>
>    checkout(int tenantId, String filePath, int depth)
>
>    2.
>
>    update(int tenantId, String rootPath, String filePathToUpdate, int depth)
>
>    3.
>
>    checkout(int tenantId, String filePath)
>
>
>  in [1] uses the code,
>
> filesUpdated = svnClient.update(root, SVNRevision.HEAD,Depth.infinity,
> NO_SET_DEPTH,ignoreExternals, forceUpdate);
>
> svnClient.update(..) returns revision number but assigned to filesUpdated.
> The method return value is set to
>
> filesUpdated >1
>
> which is incorrect. According to javadocs[2], methods should return true
> if files were checked out or updates, false otherwise. If files were
> changed, it can be detected comparing revision numbers. Therefore the
> return value would be,
>
>          long lastRevisionNumber =
> svnClient.getInfo(root).getLastChangedRevision();
>      long newRevisionNumber = svnClient.update(root,
> SVNRevision.HEAD,Depth.infinity, NO_SET_DEPTH,ignoreExternals, forceUpdate)
> ;
>
>      return newRevisionNumber>lastRevisionNumber;
>
> This gives different values for newRevisionNumberLog and
> lastRevisionNumber, when I debug with a worker node, but gave same value
> for both variables for manager node. What could be the issue here?. Log 
> messages
> should also updated accordingly. Is there any other issue to consider?
>
> [1]
> https://github.com/wso2-dev/carbon-commons/blob/master/components/deployment-synchronizer/org.wso2.carbon.deployment.synchronizer.subversion/src/main/java/org/wso2/carbon/deployment/synchronizer/subversion/SVNBasedArtifactRepository.java
>
> [2]
> https://svn.wso2.org/repos/wso2/carbon/platform/trunk/components/deployment-synchronizer/org.wso2.carbon.deployment.synchronizer/src/main/java/org/wso2/carbon/deployment/synchronizer/ArtifactRepository.java
>
> Thanks,
> Nipuni
> --
> Nipuni Perera
> Software Engineer; WSO2 Inc.; http://wso2.com
> Email: [email protected]
> Git hub profile: https://github.com/nipuni
> Mobile: +94 (71) 5626680
>
>


-- 
Nipuni Perera
Software Engineer; WSO2 Inc.; http://wso2.com
Email: [email protected]
Git hub profile: https://github.com/nipuni
Mobile: +94 (71) 5626680
<http://wso2.com>
diff --git 
a/components/deployment-synchronizer/org.wso2.carbon.deployment.synchronizer.subversion/src/main/java/org/wso2/carbon/deployment/synchronizer/subversion/SVNBasedArtifactRepository.java
 
b/components/deployment-synchronizer/org.wso2.carbon.deployment.synchronizer.subversion/src/main/java/org/wso2/carbon/deployment/synchronizer/subversion/SVNBasedArtifactRepository.java
index c8469d4..f4e7547 100644
--- 
a/components/deployment-synchronizer/org.wso2.carbon.deployment.synchronizer.subversion/src/main/java/org/wso2/carbon/deployment/synchronizer/subversion/SVNBasedArtifactRepository.java
+++ 
b/components/deployment-synchronizer/org.wso2.carbon.deployment.synchronizer.subversion/src/main/java/org/wso2/carbon/deployment/synchronizer/subversion/SVNBasedArtifactRepository.java
@@ -423,7 +423,8 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                 }
                 return true;
             } else {
-                long filesUpdated = -1;
+                long lastRevisionNumber = -1;
+                long newRevisionNumber = -1;
                 svnClient.cleanup(root);
                 int tries = 0;
                 do {
@@ -431,16 +432,18 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                         tries++;
                         if (svnClient instanceof CmdLineClientAdapter) {
                             // CmdLineClientAdapter does not support all the 
options
-                            filesUpdated = svnClient.update(root, 
SVNRevision.HEAD, RECURSIVE);
+                            lastRevisionNumber = 
svnClient.getInfo(root).getLastChangedRevision().getNumber();
+                            newRevisionNumber  = svnClient.update(root, 
SVNRevision.HEAD, RECURSIVE);
                             if (log.isDebugEnabled()) {
-                                log.debug(filesUpdated + " files were updated 
using CmdLineClientAdapter");
+                                log.debug(" files were updated to revision 
number: "+newRevisionNumber+" using CmdLineClientAdapter");
                             }
                         } else {
-                            filesUpdated = svnClient.update(root, 
SVNRevision.HEAD,
+                            lastRevisionNumber = 
svnClient.getInfo(root).getLastChangedRevision().getNumber();
+                            lastRevisionNumber = svnClient.update(root, 
SVNRevision.HEAD,
                                     Depth.infinity, NO_SET_DEPTH,
                                     ignoreExternals, forceUpdate);
                             if (log.isDebugEnabled()) {
-                                log.debug(filesUpdated + " files were updated 
using SVN Kit");
+                                log.debug("files were updated to revision 
number: " +newRevisionNumber+ " using SVN Kit");
                             }
                         }
                         break;
@@ -459,7 +462,7 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                         }
                     }
                 } while (tries < 10); // try to recover & retry
-                return filesUpdated > 1;
+                return newRevisionNumber>lastRevisionNumber;
             }
         } catch (SVNClientException e) {
             handleException("Error while checking out or updating artifacts 
from the " +
@@ -598,7 +601,8 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                 }
                 return true;
             } else {
-                long filesUpdated = -1;
+                long lastRevisionNumber = -1;
+                long newRevisionNumber = -1;
                 svnClient.cleanup(root);
                 int tries = 0;
                 do {
@@ -606,13 +610,15 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                         tries++;
                         if (svnClient instanceof CmdLineClientAdapter) {
                             // CmdLineClientAdapter does not support all the 
options
-                            filesUpdated = svnClient.update(root, 
SVNRevision.HEAD, RECURSIVE);
-                            log.info(filesUpdated + " files were updated using 
CmdLineClientAdapter");
+                            lastRevisionNumber = 
svnClient.getInfo(root).getLastChangedRevision().getNumber();
+                            newRevisionNumber = svnClient.update(root, 
SVNRevision.HEAD, RECURSIVE);
+                            log.info("files were updated to revision number: " 
+newRevisionNumber+ " using CmdLineClientAdapter");
                         } else {
-                            filesUpdated = svnClient.update(root, 
SVNRevision.HEAD,
+                            lastRevisionNumber = 
svnClient.getInfo(root).getLastChangedRevision().getNumber();
+                            newRevisionNumber = svnClient.update(root, 
SVNRevision.HEAD,
                                                             depth, 
NO_SET_DEPTH,
                                                             ignoreExternals, 
forceUpdate);
-                            log.info(filesUpdated + " files were updated using 
SVN Kit");
+                            log.info("files were updated to revision number: " 
+newRevisionNumber + " using SVN Kit");
                         }
                         break;
                     } catch (SVNClientException e) {
@@ -630,7 +636,7 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                         }
                     }
                 } while (tries < 10); // try to recover & retry
-                return filesUpdated > 1;
+                return newRevisionNumber>lastRevisionNumber;
             }
         } catch (SVNClientException e) {
             handleException("Error while checking out or updating artifacts 
from the " +
@@ -657,7 +663,8 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
         if (depth == Depth.infinity) {
             setDepth = true;
         }
-        long filesUpdated = -1;
+        long lastRevisionNumber = -1;
+        long newRevisionNumber = -1;
         try {
             svnClient.cleanup(root);
 
@@ -674,13 +681,15 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                     tries++;
                     if (svnClient instanceof CmdLineClientAdapter) {
                         // CmdLineClientAdapter does not support all the 
options
-                        filesUpdated = svnClient.update(root, 
SVNRevision.HEAD, RECURSIVE);
-                        log.info(filesUpdated + " files were updated using 
CmdLineClientAdapter");
+                        lastRevisionNumber = 
svnClient.getInfo(root).getLastChangedRevision().getNumber();
+                        newRevisionNumber = svnClient.update(root, 
SVNRevision.HEAD, RECURSIVE);
+                        log.info("files were updated to revision number: 
"+newRevisionNumber + " using CmdLineClientAdapter");
                     } else {
-                        filesUpdated = svnClient.update(root, 
filePath,SVNRevision.HEAD,
+                        lastRevisionNumber = 
svnClient.getInfo(root).getLastChangedRevision().getNumber();
+                        newRevisionNumber = svnClient.update(root, 
filePath,SVNRevision.HEAD,
                                                         depth, setDepth,
                                                         ignoreExternals, 
forceUpdate);
-                        log.info(filesUpdated + " files were updated using SVN 
Kit");
+                        log.info("files were updated to revision number: 
"+newRevisionNumber +" using SVN Kit");
                     }
                     break;
                 } catch (SVNClientException e) {
@@ -698,7 +707,7 @@ public class SVNBasedArtifactRepository implements 
ArtifactRepository {
                     }
                 }
             } while (tries < 10); // try to recover & retry
-            return filesUpdated > 1;
+            return newRevisionNumber>lastRevisionNumber;
         } catch (SVNClientException e) {
             handleException("Error while checking out or updating artifacts 
from the " +
                             "SVN repository", e);
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to