Package org.apache.stratos.cartridge.agent.artifact.deployment.synchronizer.git.internal

Examples of org.apache.stratos.cartridge.agent.artifact.deployment.synchronizer.git.internal.RepositoryContext


     
      log.info("Initializing git context.");
     
      int tenantId = Integer.parseInt(repositoryInformation.getTenantId());
      String gitLocalRepoPath = repositoryInformation.getRepoPath();
        RepositoryContext gitRepoCtx = new RepositoryContext();
        String gitRemoteRepoUrl = repositoryInformation.getRepoUrl();
        boolean isMultitenant = repositoryInformation.isMultitenant();
       
        log.info("local path " + gitLocalRepoPath);
        log.info("remote url " + gitRemoteRepoUrl);
        log.info("tenant " + tenantId);
       
        gitRepoCtx.setTenantId(tenantId);
        gitRepoCtx.setGitLocalRepoPath(getRepoPathForTenantId(tenantId,gitLocalRepoPath,isMultitenant));       
        gitRepoCtx.setGitRemoteRepoUrl(gitRemoteRepoUrl);
   
    gitRepoCtx.setRepoUsername(repositoryInformation.getRepoUsername());
    gitRepoCtx.setRepoPassword(repositoryInformation.getRepoPassword());

        try {
      if(isKeyBasedAuthentication(gitRemoteRepoUrl, tenantId)) {
          gitRepoCtx.setKeyBasedAuthentication(true);
          initSSHAuthentication();
      }
      else
          gitRepoCtx.setKeyBasedAuthentication(false);
    } catch (Exception e1) {
      log.error("Exception occurred.. " + e1.getMessage(), e1);
    }

        FileRepository localRepo = null;
        try {
            // localRepo = new FileRepository(new File(gitLocalRepoPath + "/.git"));
            // Fixing STRATOS-380
            localRepo = new FileRepository(new File(gitRepoCtx.getGitLocalRepoPath() + "/.git"));

        } catch (IOException e) {
            e.printStackTrace();
        }

        gitRepoCtx.setLocalRepo(localRepo);
        gitRepoCtx.setGit(new Git(localRepo));
        gitRepoCtx.setCloneExists(false);

        cacheGitRepoContext(tenantId, gitRepoCtx);
    }
View Full Code Here


        .entrySet()) {

      int tenantId = tenantMap.getKey();
      //log.info("map count has values..tenant Id : " + tenantId);
     
      RepositoryContext gitRepoCtx = retrieveCachedGitContext(tenantId);
      if (gitRepoCtx == null) {
       
          log.info("No git repository context information found for tenant "
              + tenantId);

        return false;
      }

      Git git = gitRepoCtx.getGit();
      StatusCommand statusCmd = git.status();
      Status status = null;
      try {
        status = statusCmd.call();

      } catch (GitAPIException e) {
        log.error(
            "Git status operation for tenant "
                + gitRepoCtx.getTenantId() + " failed, ", e);
        return false;
      }
      //log.info("status : " + status.toString());
      if (status.isClean()) {// no changes, nothing to commit
       
View Full Code Here

      // if context for tenant is not initialized
      if(tenantToRepoContextMap.get(tenantId) == null)
        initGitContext(repositoryInformation);
     
       
    RepositoryContext gitRepoCtx = retrieveCachedGitContext(tenantId);
        if(gitRepoCtx == null) { //to handle super tenant scenario
           // if(log.isDebugEnabled())
                log.info("No git repository context information found for deployment synchronizer");

            return true;
        }

        synchronized (gitRepoCtx) {
            if(!gitRepoCtx.cloneExists())
                cloneRepository(gitRepoCtx);

            return pullArtifacts(gitRepoCtx);
        }
    }
View Full Code Here

   
    public void scheduleSyncTask (RepositoryInformation repoInformation, long delay) {

        int tenantId = Integer.parseInt(repoInformation.getTenantId());

        RepositoryContext repoCtxt = tenantToRepoContextMap.get(tenantId);
        if (repoCtxt == null) {
            log.error("Unable to schedule artifact sync task, repositoryContext null for tenant " + tenantId);
            return;
        }

        if (repoCtxt.getArtifactSyncSchedular() == null) {
           synchronized (repoCtxt) {
               if (repoCtxt.getArtifactSyncSchedular() == null) {
                   // create a new ScheduledExecutorService instance
                   final ScheduledExecutorService artifactSyncScheduler = Executors.newScheduledThreadPool(1,
                           new ArtifactSyncTaskThreadFactory(repoCtxt.getGitLocalRepoPath()));

                   // schedule at the given interval
                   artifactSyncScheduler.scheduleAtFixedRate(new ArtifactSyncTask(repoInformation), delay, delay, TimeUnit.SECONDS);
                   // cache
                   repoCtxt.setArtifactSyncSchedular(artifactSyncScheduler);

                   log.info("Scheduled Artifact Synchronization Task for path " + repoCtxt.getGitLocalRepoPath());

               } else {
                   log.info("Artifact Synchronization Task for path " + repoCtxt.getGitLocalRepoPath() + " already scheduled");
               }
           }
        }
    }
View Full Code Here

      // if context for tenant is not initialized
      if(tenantToRepoContextMap.get(tenantId) == null)
        initGitContext(repositoryInformation);
     
       
    RepositoryContext gitRepoCtx = retrieveCachedGitContext(tenantId);
        if(gitRepoCtx == null) {
            return false;
        }

        /*if(gitRepoCtx.getTenantId() == GitDeploymentSynchronizerConstants.SUPER_TENANT_ID)
            return true;  */
        return gitRepoCtx.cloneExists();
    }
View Full Code Here

TOP

Related Classes of org.apache.stratos.cartridge.agent.artifact.deployment.synchronizer.git.internal.RepositoryContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.