made chagnes for restore 51/6351/1
authorvt402f <vt00325492@techmahindra.com>
Sun, 26 Jan 2020 19:12:15 +0000 (14:12 -0500)
committervt402f <vt00325492@techmahindra.com>
Sun, 26 Jan 2020 19:12:29 +0000 (14:12 -0500)
Change-Id: Id09ffcb97d0953bf3ed51503497ab3af0765fb14
Signed-off-by: vt402f <vt00325492@techmahindra.com>
elk-client/src/main/java/org/acumos/elk/client/controller/ElasticSearchServiceController.java
elk-client/src/main/java/org/acumos/elk/client/service/ISnapshotRepositoryService.java
elk-client/src/main/java/org/acumos/elk/client/service/SnapshotRepositoryServiceImpl.java
elk-client/src/main/java/org/acumos/elk/client/utils/ElkClientConstants.java

index bab1c78..a4a0f7b 100644 (file)
@@ -114,8 +114,8 @@ public class ElasticSearchServiceController extends AbstractController {
                LogConfig.setEnteringMDCs("elk-client", ElkClientConstants.SNAPSHOT_CREATE_REPOSITORY);
                String repositoryStatus = null;
                logger.debug("Inside create elasticstack repository");
-
-               repositoryStatus = snapshotGetRepositoryService.createElkRepository(elkCreateRepositoriesRequest);
+               String action = ElkClientConstants.CREATE_REQUEST;
+               repositoryStatus = snapshotGetRepositoryService.createElkRepository(elkCreateRepositoriesRequest, action);
 
                logger.debug("method call ended.");
                LogConfig.clearMDCDetails();
index aeda0f7..7e416de 100644 (file)
@@ -45,7 +45,7 @@ public interface ISnapshotRepositoryService {
         *            takes as request parameter
         * @return created status.
         */
-       public String createElkRepository(ElkRepositoriesRequest elkCreateRepositoriesRequest) throws Exception;
+       public String createElkRepository(ElkRepositoriesRequest elkCreateRepositoriesRequest, String action) throws Exception;
 
        /**
         * This method is used to delete repository.
index 289d7aa..3d9f985 100644 (file)
@@ -94,7 +94,7 @@ public class SnapshotRepositoryServiceImpl extends AbstractELKClientConnection i
                return elkRepositoriesResponse;
        }
 
-       public String createElkRepository(ElkRepositoriesRequest elkCreateRepositoriesRequest) throws Exception {
+       public String createElkRepository(ElkRepositoriesRequest elkCreateRepositoriesRequest, String action) throws Exception {
                logger.debug("Inside createElkRepository ");
                if (StringUtils.isEmpty(elkCreateRepositoriesRequest.getRepositoryName())) {
                        return "false | RepositoryName empty is not allowed";
@@ -109,11 +109,12 @@ public class SnapshotRepositoryServiceImpl extends AbstractELKClientConnection i
                }
                boolean acknowledged = false;
                if (repositoryNameSet.contains(elkCreateRepositoriesRequest.getRepositoryName())) {
-                       //throw new ELKException("false | RepositoryName already exist");
                        logger.debug("elkCreateRepositoriesRequest.getRepositoryName():{} | RepositoryName already exist", elkCreateRepositoriesRequest.getRepositoryName());
+                       throw new ELKException("false | RepositoryName already exist");
                } else {
-                       acknowledged = createRepo(elkCreateRepositoriesRequest, "backup");
-                       createRepo(elkCreateRepositoriesRequest, ElkClientConstants.ARCHIVE_ES_DATA);
+                       acknowledged = createRepo(elkCreateRepositoriesRequest, ElkClientConstants.BACKUP_REQUEST);
+                       if(!action.equalsIgnoreCase(ElkClientConstants.RESTORE_REQUEST))
+                               createRepo(elkCreateRepositoriesRequest, ElkClientConstants.ARCHIVE_ES_DATA);
 
                        logger.debug("Repository is created ", acknowledged);
                }
@@ -261,7 +262,7 @@ public class SnapshotRepositoryServiceImpl extends AbstractELKClientConnection i
                                        resultList.add(result.trim());
                                        logger.debug("resultList.size(): {}", resultList.size());
                                        if (action.equalsIgnoreCase(ElkClientConstants.DELETE_REQUEST) || action.equalsIgnoreCase(ElkClientConstants.RESTORE_REQUEST)) {
-                                               logger.debug("action.equalsIgnoreCase : ", action);
+                                               logger.debug("action.equalsIgnoreCase :{} ", action);
                                                ElkRepositoriesRequest elkDeleteRepositoriesRequest= new ElkRepositoriesRequest();
                                                elkDeleteRepositoriesRequest.setNodeTimeout(ElkClientConstants.TIME_ONE_MINT_OUT);
                                                elkDeleteRepositoriesRequest.setRepositoryName(repoName);
@@ -288,15 +289,15 @@ public class SnapshotRepositoryServiceImpl extends AbstractELKClientConnection i
                        elkArchiveResponse.setMsg("Action:" + action + " done");
                        elkArchiveResponse.setStatus(ElkClientConstants.SUCCESS);
                        elkArchiveResponse.setArchiveInfo(archiveInfoList);
-                       logger.debug("archiveInfoList:{} action:{}" + archiveInfoList, action);
+                       logger.debug("archiveInfoList:{} action:{}", archiveInfoList, action);
                        if (action.equalsIgnoreCase(ElkClientConstants.RESTORE_REQUEST)) {
                                for (ArchiveInfo archiveInfo : archiveInfoList) {
                                        ElkRepositoriesRequest elkCreateRepositoriesRequest = new ElkRepositoriesRequest();
                                        elkCreateRepositoriesRequest.setRepositoryName(archiveInfo.getRepositoryName());
-                                       logger.debug("archiveInfo.getRepositoryName():{}  action:{}" + archiveInfo.getRepositoryName(), action);
+                                       logger.debug("archiveInfo.getRepositoryName():{}  action:{}", archiveInfo.getRepositoryName(), action);
                                        elkCreateRepositoriesRequest.setNodeTimeout(ElkClientConstants.TIME_ONE_MINT_OUT);
-                                       logger.debug("elkCreateRepositoriesRequest:{}  action:{}" + elkCreateRepositoriesRequest.getRepositoryName(), action);
-                                       createElkRepository(elkCreateRepositoriesRequest);
+                                       logger.debug("elkCreateRepositoriesRequest:{}  action:{}", elkCreateRepositoriesRequest.getRepositoryName(), action);
+                                       createElkRepository(elkCreateRepositoriesRequest, action);
                                }
                        }
                        logger.debug("completed for loop of restore:{}" + archiveInfoList);
index 2c87647..2d964e8 100644 (file)
@@ -44,7 +44,9 @@ public final class ElkClientConstants {
        public static final String FAIL = "fail";
        public static final String INFO = "INFO";
        public static final String ARCHIVE_ES_DATA = "archive-es-data";
+       public static final String CREATE_REQUEST = "create";
        public static final String RESTORE_REQUEST = "restore";
        public static final String DELETE_REQUEST = "delete";
+       public static final String BACKUP_REQUEST = "backup";
        
 }