Platform maintenance support-backend impl 44/4044/7
authorAMIT M <am00474504@techmahindra.com>
Fri, 29 Mar 2019 13:52:09 +0000 (19:22 +0530)
committerAMIT M <am00474504@techmahindra.com>
Mon, 1 Apr 2019 14:40:31 +0000 (20:10 +0530)
 Issue-ID: ACUMOS-2004,2343,2344
 -List all the repository present into ElasticStack
 -Create the repository present into ElasticStack
 -Delete the repository present into ElasticStack
 -List all the snapshot present into ElasticStack
 -Create the snapshot present into ElasticStack
 -Delete the snapshot present into ElasticStack
 -Managing Schedule Cron Job for creation Log Snapshot.

Change-Id: I62d414078f77b7a4f8bba22e8d709fccb0e47bea
Signed-off-by: AMIT M <am00474504@techmahindra.com>
42 files changed:
docs/release-notes.rst
elk-client/pom.xml [new file with mode: 0644]
elk-client/src/license/acumos/header.txt [new file with mode: 0644]
elk-client/src/license/acumos/license.txt [new file with mode: 0644]
elk-client/src/license/licenses.properties [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/ElkClientServiceApplication.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/ElkLogSnapshotTaskSchedular.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/SwaggerConfiguration.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/controller/AbstractController.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/controller/ElasticSearchServiceController.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/service/AbstractELKClientConnection.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/service/ISnapshotRepositoryService.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/service/ISnapshotService.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/service/SnapshotRepositoryServiceImpl.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/service/SnapshotServiceImpl.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/CreateSnapshot.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/DeleteSnapshot.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ELkRepositoryMetaData.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElasticsearchSnapshotsResponse.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElkCreateSnapshotRequest.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElkDeleteSnapshotRequest.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElkGetRepositoriesResponse.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElkGetSnapshotMetaData.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElkRepositoriesRequest.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElkRestoreSnapshotRequest.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ElkSnapshotsResponse.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ErrorDetails.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/ErrorTransport.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/transport/RestoreSnapshot.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/client/utils/ELKClientConstants.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/logging/ACUMOSLogConstants.java [new file with mode: 0644]
elk-client/src/main/java/org/acumos/elk/logging/LogConfig.java [new file with mode: 0644]
elk-client/src/main/resources/application.properties [new file with mode: 0644]
elk-client/src/main/resources/logback.xml [new file with mode: 0644]
elk-stack/acumos-elk-env.sh
elk-stack/docker-compose.yml
elk-stack/elasticsearch/config/elasticsearch.yml
elk-stack/elasticsearch/pom.xml
elk-stack/kibana/pom.xml
elk-stack/logstash/pom.xml
filebeat/pom.xml
metricbeat/pom.xml

index fd9ff5b..4b68737 100644 (file)
 Platform Operations, Administration, and Management (OA&M) Release Notes
 ========================================================================
 
+Version 2.0.8, 29 March 2019
+-------------------------------
+* Add implementation for Platform maintenance support (`ACUMOS-2004 <https://jira.acumos.org/browse/ACUMOS-2004>`_)
+* Add implementation for Platform maintenance support (`ACUMOS-2343 <https://jira.acumos.org/browse/ACUMOS-2343>`_)
+* Add implementation for Platform maintenance support - backend (`ACUMOS-2344 <https://jira.acumos.org/browse/ACUMOS-2344>`_)
+
 Version 2.0.7, 07 February 2019
 -------------------------------
 * Add implementation for mandatory MDC default value in logging POC and bump ELK stack version to 2.0.7(`ACUMOS-2458 <https://jira.acumos.org/browse/ACUMOS-2458>`_)
diff --git a/elk-client/pom.xml b/elk-client/pom.xml
new file mode 100644 (file)
index 0000000..a09baf7
--- /dev/null
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <!-- ===============LICENSE_START======================================================= 
+               Acumos =================================================================================== 
+               Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights 
+               reserved. =================================================================================== 
+               This Acumos software file is distributed by AT&T and Tech Mahindra under 
+               the Apache License, Version 2.0 (the "License"); you may not use this file 
+               except in compliance with the License. You may obtain a copy of the License 
+               at http://www.apache.org/licenses/LICENSE-2.0 This file 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. ===============LICENSE_END========================================================= -->
+       <modelVersion>4.0.0</modelVersion>
+
+       <groupId>elk-client</groupId>
+       <artifactId>elk-client</artifactId>
+       <version>0.0.1-SNAPSHOT</version>
+       <packaging>jar</packaging>
+
+       <name>elk-client</name>
+       <description>Elk-Client service </description>
+
+       <parent>
+               <groupId>org.springframework.boot</groupId>
+               <artifactId>spring-boot-starter-parent</artifactId>
+               <version>2.1.1.RELEASE</version>
+               <!-- silence warning about parent relative path -->
+               <relativePath />
+       </parent>
+       <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+               <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+               <java.version>1.8</java.version>
+               <!-- Stand-alone RESTFul application -->
+               <start-class>org.acumos.elk.client.ElkClientServiceApplication</start-class>
+               <!-- Begin extract of POM file spring-boot-dependencies -->
+               <spring.version>5.1.2.RELEASE</spring.version>
+               <swagger.version>1.5.21</swagger.version>
+               <springfox.version>2.6.1</springfox.version>
+               <jackson.version>2.9.7</jackson.version>
+               <jackson-mapper-asl.version>1.9.9</jackson-mapper-asl.version>
+               <json.simple.version>1.1.1</json.simple.version>
+               <elasticsearch.version>6.5.4</elasticsearch.version>
+               <elasticsearch.client.version>6.5.4</elasticsearch.client.version>
+
+               <!-- tests still depend on Azure host -->
+               <skipTests>false</skipTests>
+               <!-- Jenkins invokes mvn with argument -Dbuild.number=${BUILD_NUMBER} -->
+               <build.number>0</build.number>
+               <!-- Not supplied to all jobs; e.g., Javadoc -->
+               <docker.pull.registry>nexus3.acumos.org:10001</docker.pull.registry>
+               <!--Supplied by Jenkins -->
+               <docker.push.registry>${env.NEXUS3_PUSH_REGISTRY}</docker.push.registry>
+
+       </properties>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-web</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-test</artifactId>
+                       <scope>test</scope>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.slf4j</groupId>
+                                       <artifactId>slf4j-api</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>io.springfox</groupId>
+                       <artifactId>springfox-swagger2</artifactId>
+                       <version>${springfox.version}</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.slf4j</groupId>
+                                       <artifactId>slf4j-api</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>io.swagger</groupId>
+                                       <artifactId>swagger-annotations</artifactId>
+                               </exclusion>
+                               <exclusion>
+                                       <groupId>io.swagger</groupId>
+                                       <artifactId>swagger-models</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>io.springfox</groupId>
+                       <artifactId>springfox-swagger-ui</artifactId>
+                       <version>${springfox.version}</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.slf4j</groupId>
+                                       <artifactId>slf4j-api</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>io.swagger</groupId>
+                       <artifactId>swagger-annotations</artifactId>
+                       <version>${swagger.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>io.swagger</groupId>
+                       <artifactId>swagger-models</artifactId>
+                       <version>${swagger.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-core</artifactId>
+                       <version>${spring.version}</version>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>commons-logging</groupId>
+                                       <artifactId>commons-logging</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework</groupId>
+                       <artifactId>spring-web</artifactId>
+                       <version>${spring.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-configuration-processor</artifactId>
+                       <optional>true</optional>
+
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>org.slf4j</groupId>
+                                       <artifactId>slf4j-api</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               <dependency>
+                       <groupId>com.googlecode.json-simple</groupId>
+                       <artifactId>json-simple</artifactId>
+                       <version>${json.simple.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-core</artifactId>
+                       <version>${jackson.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.fasterxml.jackson.core</groupId>
+                       <artifactId>jackson-databind</artifactId>
+                       <version>${jackson.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.codehaus.jackson</groupId>
+                       <artifactId>jackson-mapper-asl</artifactId>
+                       <version>${jackson-mapper-asl.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.elasticsearch</groupId>
+                       <artifactId>elasticsearch</artifactId>
+                       <version>${elasticsearch.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.elasticsearch.client</groupId>
+                       <artifactId>elasticsearch-rest-high-level-client</artifactId>
+                       <version>${elasticsearch.client.version}</version>
+               </dependency>
+       </dependencies>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.springframework.boot</groupId>
+                               <artifactId>spring-boot-maven-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>exec-maven-plugin</artifactId>
+                               <!-- <version>1.4.0</version> -->
+                       </plugin>
+                       <plugin>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <!-- <version>3.0</version> -->
+                               <configuration>
+                                       <source>1.8</source>
+                                       <target>1.8</target>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                               <!-- Spring sets the <version>2.5</version> -->
+                               <configuration>
+                                       <archive>
+                                               <manifest>
+                                                       <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+                                               </manifest>
+                                               <manifestEntries>
+                                                       <Implementation-Version>${project.version}-b${build.number}</Implementation-Version>
+                                               </manifestEntries>
+                                       </archive>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.jacoco</groupId>
+                               <artifactId>jacoco-maven-plugin</artifactId>
+                               <version>0.7.9</version>
+                               <executions>
+                                       <execution>
+                                               <id>default-prepare-agent</id>
+                                               <goals>
+                                                       <goal>prepare-agent</goal>
+                                               </goals>
+                                       </execution>
+                                       <execution>
+                                               <id>default-report</id>
+                                               <phase>prepare-package</phase>
+                                               <goals>
+                                                       <goal>report</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+                       <!-- https://stackoverflow.com/questions/39126226/fabric8-springboot-full-example -->
+                       <plugin>
+                               <groupId>io.fabric8</groupId>
+                               <artifactId>docker-maven-plugin</artifactId>
+                               <version>0.23.0</version>
+                               <configuration>
+                                       <verbose>true</verbose>
+                                       <!-- docker runs on the LF build minion so the default value is ok -->
+                                       <!-- LF <dockerHost>unix:///var/run/docker.sock</dockerHost> LF -->
+                                       <pullRegistry>${docker.pull.registry}</pullRegistry>
+                                       <pushRegistry>${docker.push.registry}</pushRegistry>
+                                       <!-- LF credentials are not supplied here -->
+                                       <images>
+                                               <image>
+                                                       <!-- Specify a tag to avoid default tag "latest" -->
+                                                       <name>elk-client:${project.version}</name>
+                                                       <build>
+                                                               <from>openjdk:8-jre-slim</from>
+                                                               <tags>
+                                                                       <!-- Add tag with build number -->
+                                                                       <tag>${project.version}-b${build.number}</tag>
+                                                               </tags>
+                                                               <assembly>
+                                                                       <inline>
+                                                                               <files>
+                                                                                       <file>
+                                                                                               <source>target/${project.artifactId}-${project.version}.${project.packaging}</source>
+                                                                                               <outputDirectory />
+                                                                                       </file>
+                                                                               </files>
+                                                                       </inline>
+                                                               </assembly>
+                                                               <cmd>
+                                                                       <!-- CDATA prevents Eclipse formatter from breaking line -->
+                                                                       <shell><![CDATA[cd /maven; java -Xms128m -Xmx1024m -Djava.security.egd=file:/dev/./urandom -jar ${project.artifactId}-${project.version}.${project.packaging}]]></shell>
+                                                               </cmd>
+                                                       </build>
+                                               </image>
+                                       </images>
+                               </configuration>
+                               <!-- build Docker images in install phase, push in deploy phase -->
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>build</goal>
+                                                       <goal>push</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+</project>
diff --git a/elk-client/src/license/acumos/header.txt b/elk-client/src/license/acumos/header.txt
new file mode 100644 (file)
index 0000000..573b615
--- /dev/null
@@ -0,0 +1,11 @@
+This Acumos software file is distributed by AT&T and Tech Mahindra
+under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+     http://www.apache.org/licenses/LICENSE-2.0
+This file 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.
diff --git a/elk-client/src/license/acumos/license.txt b/elk-client/src/license/acumos/license.txt
new file mode 100644 (file)
index 0000000..261eeb9
--- /dev/null
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   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.
diff --git a/elk-client/src/license/licenses.properties b/elk-client/src/license/licenses.properties
new file mode 100644 (file)
index 0000000..baec26d
--- /dev/null
@@ -0,0 +1,22 @@
+###
+# ===============LICENSE_START=======================================================
+# Acumos
+# ===================================================================================
+# Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+# ===================================================================================
+# This Acumos software file is distributed by AT&T and Tech Mahindra
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#  
+#      http://www.apache.org/licenses/LICENSE-2.0
+#  
+# This file 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.
+# ===============LICENSE_END=========================================================
+###
+
+# for mojohaus.org/license-maven-plugin v1.14
+acumos=Acumos
diff --git a/elk-client/src/main/java/org/acumos/elk/client/ElkClientServiceApplication.java b/elk-client/src/main/java/org/acumos/elk/client/ElkClientServiceApplication.java
new file mode 100644 (file)
index 0000000..6ccc73a
--- /dev/null
@@ -0,0 +1,53 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client;
+
+import java.lang.invoke.MethodHandles;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+@SpringBootApplication
+@EnableScheduling
+public class ElkClientServiceApplication {
+
+       public static final String CONFIG_ENV_VAR_NAME = "SPRING_APPLICATION_JSON";
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+       public static void main(String[] args) throws Exception {
+               final String springApplicationJson = System.getenv(CONFIG_ENV_VAR_NAME);
+               if (springApplicationJson != null && springApplicationJson.contains("{")) {
+                       final ObjectMapper mapper = new ObjectMapper();
+                       // ensure it's valid
+                       mapper.readTree(springApplicationJson);
+                       logger.info("main: successfully parsed configuration from environment {}", CONFIG_ENV_VAR_NAME);
+               } else {
+                       logger.warn("main: no configuration found in environment {}", CONFIG_ENV_VAR_NAME);
+                       logger.debug("main: successfully parsed configuration from environment {}", CONFIG_ENV_VAR_NAME);
+               }
+               SpringApplication.run(ElkClientServiceApplication.class, args);
+       }
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/ElkLogSnapshotTaskSchedular.java b/elk-client/src/main/java/org/acumos/elk/client/ElkLogSnapshotTaskSchedular.java
new file mode 100644 (file)
index 0000000..1f1bfb0
--- /dev/null
@@ -0,0 +1,102 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client;
+
+import java.lang.invoke.MethodHandles;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.acumos.elk.client.service.ISnapshotRepositoryService;
+import org.acumos.elk.client.service.ISnapshotService;
+import org.acumos.elk.client.transport.CreateSnapshot;
+import org.acumos.elk.client.transport.ELkRepositoryMetaData;
+import org.acumos.elk.client.transport.ElasticsearchSnapshotsResponse;
+import org.acumos.elk.client.transport.ElkCreateSnapshotRequest;
+import org.acumos.elk.client.transport.ElkGetRepositoriesResponse;
+import org.acumos.elk.client.transport.ElkGetSnapshotMetaData;
+import org.acumos.elk.client.transport.ElkSnapshotsResponse;
+import org.acumos.elk.client.utils.ElkClientConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * Managing Schedule cron job for snapshot creation.
+ *
+ */
+@Component
+public class ElkLogSnapshotTaskSchedular {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+       private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+       @Autowired
+       ISnapshotService snapshotService;
+
+       @Autowired
+       ISnapshotRepositoryService snapshotGetRepositoryService;
+
+       @Scheduled(cron = "${elk.cronschedule.createsnapshot.time}")
+       public void createLogSnapshot() throws Exception {
+               logger.debug("Inside createLogSnapshot");
+               logger.info("The time is now {}", dateFormat.format(new Date()));
+               try {
+
+                       ElkGetRepositoriesResponse elkGetRepositoriesResponse = snapshotGetRepositoryService.getAllElkRepository();
+                       List<ELkRepositoryMetaData> repositories = elkGetRepositoriesResponse.getRepositories();
+
+                       for (ELkRepositoryMetaData eLkRepositoryMetaData : repositories) {
+                               ElkCreateSnapshotRequest createDeleteSnapshotRequest = new ElkCreateSnapshotRequest();
+                               List<CreateSnapshot> createSnapshots = new ArrayList<>();
+                               CreateSnapshot createSnapshot = new CreateSnapshot();
+                               createSnapshot.setCreate(ElkClientConstants.TRUE);
+                               createSnapshot.setRepositoryName(eLkRepositoryMetaData.getName());
+                               createSnapshots.add(createSnapshot);
+                               createDeleteSnapshotRequest.setCreateSnapshots(createSnapshots);
+                               createDeleteSnapshotRequest.setNodeTimeout("1");
+                               ElkSnapshotsResponse response = snapshotService
+                                               .createElasticSearchSnapshot(createDeleteSnapshotRequest);
+                               List<ElasticsearchSnapshotsResponse> elasticsearchSnapshots = response.getElasticsearchSnapshots();
+
+                               for (ElasticsearchSnapshotsResponse elasticsearchSnapshotsResponse : elasticsearchSnapshots) {
+                                       logger.debug("RepositoryName: {}", elasticsearchSnapshotsResponse.getRepositoryName());
+                                       List<ElkGetSnapshotMetaData> snapshots = elasticsearchSnapshotsResponse.getSnapshots();
+                                       for (ElkGetSnapshotMetaData elkGetSnapshotMetaData : snapshots) {
+                                               logger.debug(
+                                                               "\n########################################## " + "\n SnapShotId:{}  \nStatus:{}"
+                                                                               + "\n########################################## ",
+                                                               elkGetSnapshotMetaData.getSnapShotId(), elkGetSnapshotMetaData.getStatus());
+                                       }
+                               }
+
+                       }
+
+               } catch (Exception e) {
+                       logger.debug("Exception", e);
+                       throw e;
+               }
+               logger.info("The time is now {}", dateFormat.format(new Date()));
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/SwaggerConfiguration.java b/elk-client/src/main/java/org/acumos/elk/client/SwaggerConfiguration.java
new file mode 100644 (file)
index 0000000..32fcfd8
--- /dev/null
@@ -0,0 +1,62 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+
+package org.acumos.elk.client;
+
+import org.acumos.elk.client.controller.AbstractController;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+public class SwaggerConfiguration {
+       @Bean
+       public Docket api() {
+               return new Docket(DocumentationType.SWAGGER_2).select() //
+                               .apis(RequestHandlerSelectors.basePackage(AbstractController.class.getPackage().getName())) //
+                               .paths(PathSelectors.any()) //
+                               .build() //
+                               .apiInfo(apiInfo());
+       }
+
+       private ApiInfo apiInfo() {
+               final String version = ElkClientServiceApplication.class.getPackage().getImplementationVersion();
+               return new ApiInfoBuilder() //
+                               .title("Acumos ELk Client REST API") //
+                               .description("Provides create, retrieve, restore and delete snapshot services for " //
+                                               + " Operations for Elastic stack. ")
+                               .termsOfServiceUrl("Terms of service") //
+                               .contact(new Contact("Acumos Team", //
+                                               "https://acumos.org/to-be-determined", //
+                                               "contact@acumos.org")) //
+                               .license("Apache 2.0 License").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0") //
+                               .version(version == null ? "version not available" : version) //
+                               .build();
+       }
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/controller/AbstractController.java b/elk-client/src/main/java/org/acumos/elk/client/controller/AbstractController.java
new file mode 100644 (file)
index 0000000..cce070c
--- /dev/null
@@ -0,0 +1,33 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+
+package org.acumos.elk.client.controller;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public abstract class AbstractController {
+
+       protected final ObjectMapper mapper;
+
+       public AbstractController() {
+               mapper = new ObjectMapper();
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/controller/ElasticSearchServiceController.java b/elk-client/src/main/java/org/acumos/elk/client/controller/ElasticSearchServiceController.java
new file mode 100644 (file)
index 0000000..e5b7469
--- /dev/null
@@ -0,0 +1,177 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.controller;
+
+import java.lang.invoke.MethodHandles;
+import java.util.Date;
+
+import org.acumos.elk.client.service.ISnapshotRepositoryService;
+import org.acumos.elk.client.service.ISnapshotService;
+import org.acumos.elk.client.transport.ElkCreateSnapshotRequest;
+import org.acumos.elk.client.transport.ElkDeleteSnapshotRequest;
+import org.acumos.elk.client.transport.ElkGetRepositoriesResponse;
+import org.acumos.elk.client.transport.ElkRepositoriesRequest;
+import org.acumos.elk.client.transport.ElkRestoreSnapshotRequest;
+import org.acumos.elk.client.transport.ElkSnapshotsResponse;
+import org.acumos.elk.client.transport.ErrorDetails;
+import org.acumos.elk.client.transport.ErrorTransport;
+import org.acumos.elk.client.utils.ElkClientConstants;
+import org.acumos.elk.logging.LogConfig;
+import org.elasticsearch.ElasticsearchException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.context.request.WebRequest;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * Operation related to Acumos elastic stack platform. Create, Delete, List repository and snapshot are operation provide.
+ */
+@RestController
+public class ElasticSearchServiceController extends AbstractController {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+       @Autowired
+       ISnapshotService snapshotService;
+
+       @Autowired
+       ISnapshotRepositoryService snapshotGetRepositoryService;
+
+       @ApiOperation(value = "Get all the elasticsearch repositories details of Elasticstack.")
+       @RequestMapping(value = ElkClientConstants.GET_ALL_REPOSITORIES, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+       public ResponseEntity<ElkGetRepositoriesResponse> getElkRepository() throws Exception {
+               LogConfig.setEnteringMDCs("elk-client",ElkClientConstants.GET_ALL_REPOSITORIES);
+               logger.debug("Inside getElkRepository Service");
+               ElkGetRepositoriesResponse response = snapshotGetRepositoryService.getAllElkRepository();
+               logger.debug("method call ended.");
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<ElkGetRepositoriesResponse>(response, null, HttpStatus.OK);
+       }
+
+       @ApiOperation(value = "Create Elasticstack repository.")
+       @RequestMapping(value = ElkClientConstants.SNAPSHOT_CREATE_REPOSITORY, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
+       public ResponseEntity<String> createElkRepository(@RequestBody ElkRepositoriesRequest elkCreateRepositoriesRequest)
+                       throws Exception {
+               LogConfig.setEnteringMDCs("elk-client",ElkClientConstants.SNAPSHOT_CREATE_REPOSITORY);
+               logger.debug("Inside create elasticstack repository");
+               String repositoryStatus = snapshotGetRepositoryService.createElkRepository(elkCreateRepositoriesRequest);
+               logger.debug("method call ended.");
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<String>(repositoryStatus, null, HttpStatus.OK);
+       }
+
+       @ApiOperation(value = "Delete Elasticstack repository.")
+       @RequestMapping(value = ElkClientConstants.SNAPSHOT_DELETE_REPOSITORY_REQUEST, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
+       public ResponseEntity<String> deleteElkRepository(@RequestBody ElkRepositoriesRequest elkDeleteRepositoriesRequest)
+                       throws Exception {
+               LogConfig.setEnteringMDCs("elk-client",ElkClientConstants.SNAPSHOT_DELETE_REPOSITORY_REQUEST);
+               logger.debug("Inside delete elasticstack repository");
+               String repositoryStatus = snapshotGetRepositoryService.deleteElkRepository(elkDeleteRepositoriesRequest);
+               logger.debug("method call ended.");
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<String>(repositoryStatus, null, HttpStatus.OK);
+       }
+
+       @ApiOperation(value = "Get all the elasticsearch snapshot.", response = ElkSnapshotsResponse.class)
+       @RequestMapping(value = ElkClientConstants.GET_ALL_SNAPSHOTS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
+       public ElkSnapshotsResponse getElkSnapshot() throws Exception {
+               LogConfig.setEnteringMDCs("elk-client",ElkClientConstants.GET_ALL_SNAPSHOTS);
+               logger.debug("Inside get elasticstack snapshot");
+               ElkRepositoriesRequest elkRepositoriesRequest = new ElkRepositoriesRequest();
+               ElkSnapshotsResponse response = snapshotService.getAllElasticSearchSnapshot(elkRepositoriesRequest);
+               logger.debug("method call ended.");
+               LogConfig.clearMDCDetails();
+               return response;
+       }
+
+       @ApiOperation(value = "Create elasticstack snapshot.")
+       @RequestMapping(value = ElkClientConstants.CREATE_SNAPSHOT_REQUEST, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
+       public ResponseEntity<ElkSnapshotsResponse> createElkSnapshot(
+                       @RequestBody ElkCreateSnapshotRequest createDeleteSnapshotRequest) throws Exception {
+               LogConfig.setEnteringMDCs("elk-client",ElkClientConstants.CREATE_SNAPSHOT_REQUEST);
+               logger.debug("Inside create elasticstack repository");
+               ElkSnapshotsResponse response = snapshotService.createElasticSearchSnapshot(createDeleteSnapshotRequest);
+               logger.debug("method call ended.");
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<ElkSnapshotsResponse>(response, null, HttpStatus.OK);
+       }
+
+       @ApiOperation(value = "Delete elasticstack snapshot.")
+       @RequestMapping(value = ElkClientConstants.DELETE_SNAPSHOT_REQUEST, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
+       public ResponseEntity<ElkSnapshotsResponse> deleteElkSnapshot(
+                       @RequestBody ElkDeleteSnapshotRequest elkDeleteSnapshotRequest) throws Exception {
+               LogConfig.setEnteringMDCs("elk-client",ElkClientConstants.DELETE_SNAPSHOT_REQUEST);
+               logger.debug("Inside create elasticstack repository");
+               ElkSnapshotsResponse response = snapshotService.deleteElasticSearchSnapshot(elkDeleteSnapshotRequest);
+               logger.debug("method call ended.");
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<ElkSnapshotsResponse>(response, null, HttpStatus.OK);
+       }
+
+       @ApiOperation(value = "Restore elasticstack snapshot.")
+       @RequestMapping(value = ElkClientConstants.RESTORE_SNAPSHOT_REQUEST, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
+       public ResponseEntity<ElkSnapshotsResponse> restoreElkSnapshot(
+                       @RequestBody ElkRestoreSnapshotRequest elkRestoreSnapshotRequest) throws Exception {
+               LogConfig.setEnteringMDCs("elk-client",ElkClientConstants.RESTORE_SNAPSHOT_REQUEST);
+               logger.debug("Inside restore elasticstack snapshot");
+               snapshotService.restoreElasticSearchSnapshot(elkRestoreSnapshotRequest);
+               logger.debug("restore method call ended.");
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<ElkSnapshotsResponse>(new ElkSnapshotsResponse(), null, HttpStatus.OK);
+       }
+
+       @ResponseStatus(HttpStatus.NOT_FOUND)
+       @ExceptionHandler(ErrorTransport.class)
+       public ResponseEntity<ErrorDetails> handleTransportError(ErrorTransport ex, WebRequest request) {
+               logger.error("IOException handler executed");
+               ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<>(errorDetails, HttpStatus.BAD_REQUEST);
+       }
+
+       @ResponseStatus(HttpStatus.NOT_FOUND)
+       @ExceptionHandler(Exception.class)
+       public ResponseEntity<ErrorDetails> handleException(Exception ex, WebRequest request) {
+               logger.error("IOException handler executed");
+               ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<>(errorDetails, HttpStatus.SERVICE_UNAVAILABLE);
+       }
+
+       @ResponseStatus(HttpStatus.NOT_FOUND)
+       @ExceptionHandler(ElasticsearchException.class)
+       public ResponseEntity<ErrorDetails> handleElasticsearchException(ElasticsearchException ex, WebRequest request) {
+               logger.error("IOException handler executed");
+               ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
+               LogConfig.clearMDCDetails();
+               return new ResponseEntity<>(errorDetails, HttpStatus.SERVICE_UNAVAILABLE);
+       }
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/service/AbstractELKClientConnection.java b/elk-client/src/main/java/org/acumos/elk/client/service/AbstractELKClientConnection.java
new file mode 100644 (file)
index 0000000..5dc6eb7
--- /dev/null
@@ -0,0 +1,69 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.service;
+
+import java.lang.invoke.MethodHandles;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.acumos.elk.client.transport.ErrorTransport;
+import org.apache.http.HttpHost;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+
+public abstract class AbstractELKClientConnection {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+       @Autowired
+       private Environment env;
+
+       public void setEnvironment(Environment env1) {
+               env = env1;
+       }
+
+       public RestHighLevelClient restHighLevelClientConnection() {
+
+               String elk_host_ip =  getHostIP(env.getProperty("elk.host.url"));
+               int elk_elasticssearch_port = Integer.valueOf(env.getProperty("elk.elasticssearch.port"));
+
+               RestHighLevelClient client = new RestHighLevelClient(
+                               RestClient.builder(new HttpHost(elk_host_ip, elk_elasticssearch_port, "http")));
+               return client;
+       }
+
+       private String getHostIP(String url) {
+               try {
+            InetAddress host = InetAddress.getByName(url);
+            System.out.println(host.getHostAddress());
+            logger.debug("Elasticssearch Host IP:", host.getHostAddress());
+            return host.getHostAddress();
+        } catch (UnknownHostException ex) {
+            logger.error("UnknownHostException:", ex);
+            throw new ErrorTransport("Unable to connect Elasticserach");
+        }
+       }
+       
+       
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/service/ISnapshotRepositoryService.java b/elk-client/src/main/java/org/acumos/elk/client/service/ISnapshotRepositoryService.java
new file mode 100644 (file)
index 0000000..ea5e3e4
--- /dev/null
@@ -0,0 +1,56 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.service;
+
+import org.acumos.elk.client.transport.ElkGetRepositoriesResponse;
+import org.acumos.elk.client.transport.ElkRepositoriesRequest;
+
+/** 
+ * This interface defines method for elastic stack repository operation. 
+ *
+ * */
+public interface ISnapshotRepositoryService {
+
+       /**
+        * This method will return all the repository present in elastic stack.
+        * 
+        * @return ElkGetRepositoriesResponse
+        */
+       public ElkGetRepositoriesResponse getAllElkRepository();
+
+       /**
+        * This method is used to create repository.
+        * 
+        * @param elkCreateRepositoriesRequest
+        *            takes as request parameter
+        * @return created status.
+        */
+       public String createElkRepository(ElkRepositoriesRequest elkCreateRepositoriesRequest);
+
+       /**
+        * This method is used to delete repository.
+        * 
+        * @param elkDeleteRepositoriesRequest
+        *            takes repository details.
+        * @return delete status.
+        */
+       public String deleteElkRepository(ElkRepositoriesRequest elkDeleteRepositoriesRequest);
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/service/ISnapshotService.java b/elk-client/src/main/java/org/acumos/elk/client/service/ISnapshotService.java
new file mode 100644 (file)
index 0000000..ded22f0
--- /dev/null
@@ -0,0 +1,72 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.service;
+
+import java.io.IOException;
+
+import org.acumos.elk.client.transport.ElkCreateSnapshotRequest;
+import org.acumos.elk.client.transport.ElkDeleteSnapshotRequest;
+import org.acumos.elk.client.transport.ElkRepositoriesRequest;
+import org.acumos.elk.client.transport.ElkRestoreSnapshotRequest;
+import org.acumos.elk.client.transport.ElkSnapshotsResponse;
+
+/** This interface defines method for elastic stack snapshot operation. */
+public interface ISnapshotService {
+
+       /**
+        * This method will return all the repository present in elastic stack.
+        * 
+        * @param elkRepositoriesRequest
+        *            takes repository details.
+        * @return ElkSnapshotsResponse contains all the snapshot details.
+        */
+       public ElkSnapshotsResponse getAllElasticSearchSnapshot(ElkRepositoriesRequest elkRepositoriesRequest);
+
+       /**
+        * This method is used to create Snapshot.
+        * 
+        * @param createDeleteSnapshotRequest
+        *            takes as request parameter
+        * @return ElkSnapshotsResponse contains snapshot creation status
+        * @throws Exception
+        */
+       public ElkSnapshotsResponse createElasticSearchSnapshot(ElkCreateSnapshotRequest createDeleteSnapshotRequest)
+                       throws Exception;
+
+       /**
+        * This method is used to delete Snapshot.
+        * 
+        * @param deleteSnapshotRequest
+        *            takes as request parameter
+        * @return ElkSnapshotsResponse contains snapshot delete status
+        */
+       public ElkSnapshotsResponse deleteElasticSearchSnapshot(ElkDeleteSnapshotRequest deleteSnapshotRequest);
+
+       /**
+        * This method is used to restore Snapshot.
+        * 
+        * @param elkRestoreSnapshotRequest
+        *            takes as request parameter
+        * @return contains snapshot restore status
+        * @throws IOException 
+        */
+       public ElkSnapshotsResponse restoreElasticSearchSnapshot(ElkRestoreSnapshotRequest elkRestoreSnapshotRequest) throws IOException;
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/service/SnapshotRepositoryServiceImpl.java b/elk-client/src/main/java/org/acumos/elk/client/service/SnapshotRepositoryServiceImpl.java
new file mode 100644 (file)
index 0000000..d9b6d1c
--- /dev/null
@@ -0,0 +1,154 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.service;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.acumos.elk.client.transport.ELkRepositoryMetaData;
+import org.acumos.elk.client.transport.ElkGetRepositoriesResponse;
+import org.acumos.elk.client.transport.ElkRepositoriesRequest;
+import org.acumos.elk.client.transport.ErrorTransport;
+import org.acumos.elk.client.utils.ElkClientConstants;
+import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
+import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesRequest;
+import org.elasticsearch.action.admin.cluster.repositories.get.GetRepositoriesResponse;
+import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.cluster.metadata.RepositoryMetaData;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.repositories.fs.FsRepository;
+import org.json.simple.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * Implementation of operation related to elastic stack repository.
+ *
+ */
+@Service
+public class SnapshotRepositoryServiceImpl extends AbstractELKClientConnection implements ISnapshotRepositoryService {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+       @Override
+       public ElkGetRepositoriesResponse getAllElkRepository() {
+
+               logger.debug("Inside getAllElkRepository ");
+               RestHighLevelClient client = restHighLevelClientConnection();
+               GetRepositoriesRequest request1 = new GetRepositoriesRequest();
+               request1.repositories();
+               request1.local(true);
+
+               try {
+                       GetRepositoriesResponse response = client.snapshot().getRepository(request1, RequestOptions.DEFAULT);
+                       List<RepositoryMetaData> repositoryMetaDataResponse = response.repositories();
+                       logger.debug("Number of repositoryMetaDataResponse size {}", repositoryMetaDataResponse.size());
+
+                       ElkGetRepositoriesResponse elkRepositoriesResponse = new ElkGetRepositoriesResponse();
+                       List<ELkRepositoryMetaData> repositories = new ArrayList<>();
+                       for (RepositoryMetaData snapshotStatusResponse : repositoryMetaDataResponse) {
+
+                               logger.debug("\nNAME: {}", snapshotStatusResponse.name());
+                               logger.debug("TYPE: {}", snapshotStatusResponse.type());
+                               logger.debug("SETTINGS: {}", snapshotStatusResponse.settings());
+
+                               ELkRepositoryMetaData repositoryMetaData = new ELkRepositoryMetaData();
+                               repositoryMetaData.setName(snapshotStatusResponse.name());
+                               repositoryMetaData.setType(snapshotStatusResponse.type());
+
+                               JSONObject settings = new JSONObject();
+                               for (String key : snapshotStatusResponse.settings().keySet()) {
+                                       settings.put(key, snapshotStatusResponse.settings().get(key));
+                               }
+                               repositoryMetaData.setSettings(settings);
+                               repositories.add(repositoryMetaData);
+                       }
+                       elkRepositoriesResponse.setRepositories(repositories);
+                       client.close();
+                       return elkRepositoriesResponse;
+               } catch (Exception ex) {
+                       logger.debug("Exception:", ex);
+                       throw new ErrorTransport("Unable to connect Elasticserach");
+               }
+
+       }
+
+       public String createElkRepository(ElkRepositoriesRequest elkCreateRepositoriesRequest) {
+
+               logger.debug("Inside createElkRepository ");
+               RestHighLevelClient client = restHighLevelClientConnection();
+               PutRepositoryRequest request = new PutRepositoryRequest();
+               String locationKey = FsRepository.LOCATION_SETTING.getKey();
+               String locationValue = ".";
+               String compressKey = FsRepository.COMPRESS_SETTING.getKey();
+               boolean compressValue = true;
+               Settings settings = Settings.builder().put(locationKey, locationValue).put(compressKey, compressValue).build();
+               request.settings(settings);
+               request.name(elkCreateRepositoriesRequest.getRepositoryName());
+               request.type(FsRepository.TYPE);
+               request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
+               request.masterNodeTimeout(ElkClientConstants.TIME_ONE_MINT_OUT);
+               request.verify(true);
+               AcknowledgedResponse acknowledgedResponse;
+               boolean acknowledged = false;
+               try {
+                       acknowledgedResponse = client.snapshot().createRepository(request, RequestOptions.DEFAULT);
+                       acknowledged = acknowledgedResponse.isAcknowledged();
+                       client.close();
+               } catch (IOException ex) {
+                       logger.debug("Exception:", ex);
+                       throw new ErrorTransport("Unable to connect Elasticserach");
+               }
+
+               logger.debug("Repository is created(true for created)  {}", acknowledged);
+               return String.valueOf(acknowledged);
+       }
+
+       @Override
+       public String deleteElkRepository(ElkRepositoriesRequest elkDeleteRepositoriesRequest) {
+
+               logger.debug("Inside deleteElkRepository");
+               RestHighLevelClient client = restHighLevelClientConnection();
+               DeleteRepositoryRequest deleteRepositoryRequest = new DeleteRepositoryRequest(
+                               elkDeleteRepositoriesRequest.getRepositoryName());
+               deleteRepositoryRequest.masterNodeTimeout(elkDeleteRepositoriesRequest.getNodeTimeout());
+               AcknowledgedResponse deleteAcknowledgedResponse;
+               try {
+                       deleteAcknowledgedResponse = client.snapshot().deleteRepository(deleteRepositoryRequest,
+                                       RequestOptions.DEFAULT);
+                       client.close();
+               } catch (IOException ex) {
+                       logger.debug("Exception:", ex);
+                       throw new ErrorTransport("Unable to connect Elasticserach");
+               }
+               boolean deleteAcknowledged = deleteAcknowledgedResponse.isAcknowledged();
+               logger.debug("Repository is delete(true for created)... {}", deleteAcknowledged);
+
+               return String.valueOf(deleteAcknowledged);
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/service/SnapshotServiceImpl.java b/elk-client/src/main/java/org/acumos/elk/client/service/SnapshotServiceImpl.java
new file mode 100644 (file)
index 0000000..3b13156
--- /dev/null
@@ -0,0 +1,328 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.service;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.text.Format;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.acumos.elk.client.transport.CreateSnapshot;
+import org.acumos.elk.client.transport.DeleteSnapshot;
+import org.acumos.elk.client.transport.ELkRepositoryMetaData;
+import org.acumos.elk.client.transport.ElasticsearchSnapshotsResponse;
+import org.acumos.elk.client.transport.ElkCreateSnapshotRequest;
+import org.acumos.elk.client.transport.ElkDeleteSnapshotRequest;
+import org.acumos.elk.client.transport.ElkGetRepositoriesResponse;
+import org.acumos.elk.client.transport.ElkGetSnapshotMetaData;
+import org.acumos.elk.client.transport.ElkRepositoriesRequest;
+import org.acumos.elk.client.transport.ElkRestoreSnapshotRequest;
+import org.acumos.elk.client.transport.ElkSnapshotsResponse;
+import org.acumos.elk.client.transport.ErrorTransport;
+import org.acumos.elk.client.transport.RestoreSnapshot;
+import org.acumos.elk.client.utils.ElkClientConstants;
+import org.elasticsearch.ElasticsearchException;
+import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
+import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
+import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
+import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
+import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
+import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
+import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.rest.RestStatus;
+import org.elasticsearch.snapshots.SnapshotInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Implementation of operation related to elastic stack snapshot. 
+ *
+ */
+@Service
+public class SnapshotServiceImpl  extends AbstractELKClientConnection implements ISnapshotService {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+       
+       @Autowired
+       SnapshotRepositoryServiceImpl snapshotRepositoryServiceImpl;
+       
+       @Override
+       public ElkSnapshotsResponse getAllElasticSearchSnapshot(ElkRepositoriesRequest elkRepositoriesRequest) {
+
+               logger.debug("inside getAllElasticSearchSnapshot method ");
+               ElkSnapshotsResponse elkSnapshotsResponse = new ElkSnapshotsResponse();
+               List<ElasticsearchSnapshotsResponse> elasticsearchSnapshotsResponseList = new ArrayList<>();
+               ElkGetRepositoriesResponse elkGetRepositoriesResponse = snapshotRepositoryServiceImpl.getAllElkRepository();
+               List<ELkRepositoryMetaData> repositories = elkGetRepositoriesResponse.getRepositories();
+               for (ELkRepositoryMetaData eLkRepositoryMetaData : repositories) {
+                       ElasticsearchSnapshotsResponse elasticsearchSnapshotsResponse = getElasticsearchSnapshotDetails(
+                                       elkRepositoriesRequest, eLkRepositoryMetaData.getName());
+                       elasticsearchSnapshotsResponse.setRepositoryName(eLkRepositoryMetaData.getName());
+                       elasticsearchSnapshotsResponseList.add(elasticsearchSnapshotsResponse);
+
+               }
+               elkSnapshotsResponse.setElasticsearchSnapshots(elasticsearchSnapshotsResponseList);
+
+               return elkSnapshotsResponse;
+       }
+
+       @Override
+       public ElkSnapshotsResponse createElasticSearchSnapshot(ElkCreateSnapshotRequest createDeleteSnapshotRequest)
+                       throws Exception {
+
+               logger.debug("Inside createElasticSearchSnapshot service method");
+               ElkSnapshotsResponse elkSnapshotsResponse = new ElkSnapshotsResponse();
+               if (createDeleteSnapshotRequest.getCreateSnapshots() != null
+                               && !createDeleteSnapshotRequest.getCreateSnapshots().isEmpty()) {
+                       String snapshotName = null;
+                       ElasticsearchSnapshotsResponse snapshotResponse = new ElasticsearchSnapshotsResponse();
+                       List<CreateSnapshot> createSnapshots = createDeleteSnapshotRequest.getCreateSnapshots();
+                       for (CreateSnapshot createSnapshot : createSnapshots) {
+                               CreateSnapshotRequest createSnapshotRequest = new CreateSnapshotRequest();
+                               if (createDeleteSnapshotRequest.getNodeTimeout() != null
+                                               && Long.parseLong(createDeleteSnapshotRequest.getNodeTimeout()) > 2) {
+                                       createSnapshotRequest.masterNodeTimeout(
+                                                       TimeValue.timeValueMinutes(Long.parseLong(createDeleteSnapshotRequest.getNodeTimeout())));
+                               } else {
+                                       createSnapshotRequest.masterNodeTimeout(ElkClientConstants.TIME_TWO_MINT_OUT);
+                               }
+                               createSnapshotRequest.repository(createSnapshot.getRepositoryName());
+                               if (createSnapshot.getCreate() != null && createSnapshot.getCreate().equalsIgnoreCase(ElkClientConstants.TRUE)) {
+                                       LocalDateTime dateTime = LocalDateTime.ofInstant(new Date().toInstant(), ZoneId.systemDefault());
+                                       String dateWithTime = dateTime.toString().replaceAll(":", "-")
+                                                       .substring(0, dateTime.toString().length() - 4).toLowerCase();
+                                       snapshotName = "snapshot-" + dateWithTime;
+                                       createSnapshotRequest.snapshot(snapshotName);
+                               }
+
+                               RestHighLevelClient client = restHighLevelClientConnection();
+                               CreateSnapshotResponse createSnapshotResponse;
+                               try {
+                                       logger.debug("Before snapshot create");
+                                       createSnapshotResponse = client.snapshot().create(createSnapshotRequest, RequestOptions.DEFAULT);
+                               } catch (ElasticsearchException ex) {
+                                       logger.debug("ElasticsearchException:", ex);
+                                       throw ex;
+                               }catch (Exception ex) {
+                                       logger.debug("Exception:", ex);
+                                       throw ex;
+                               } finally {
+                                       if (client != null) {
+                                               client.close();
+                                       }
+                               }
+                               if (createSnapshotResponse != null && createSnapshotResponse.getSnapshotInfo() != null) {
+                                       SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
+                                       RestStatus status = createSnapshotResponse.status();
+                                       logger.debug("\nSnapshotInfo \n snapshotId: {}", snapshotInfo.snapshotId());
+                                       logger.debug("status: {}", snapshotInfo.status());
+                                       logger.debug("state: {}", snapshotInfo.state());
+                                       logger.debug("startTime: {}", snapshotInfo.startTime());
+                                       logger.debug("endTime: {}", snapshotInfo.endTime());
+                                       logger.debug("successfulShards: {}", snapshotInfo.successfulShards());
+                                       logger.debug("RestStatus: " + status.getStatus());
+
+                                       List<ElasticsearchSnapshotsResponse> elasticsearchSnapshotsResponseList = new ArrayList<>();
+                                       List<ElkGetSnapshotMetaData> snapshotMetaDatas = new ArrayList<>();
+                                       ElkGetSnapshotMetaData elkGetSnapshotMetaData = new ElkGetSnapshotMetaData();
+                                       elkGetSnapshotMetaData.setSnapShotId(snapshotInfo.snapshotId().toString());
+                                       elkGetSnapshotMetaData.setStatus(snapshotInfo.status().toString());
+                                       elkGetSnapshotMetaData.setState(snapshotInfo.state().toString());
+                                       elkGetSnapshotMetaData.setStartTime(String.valueOf(snapshotInfo.startTime()));
+                                       elkGetSnapshotMetaData.setEndTime(String.valueOf(snapshotInfo.endTime()));
+                                       snapshotMetaDatas.add(elkGetSnapshotMetaData);
+                                       snapshotResponse.setSnapshots(snapshotMetaDatas);
+                                       snapshotResponse.setRepositoryName(createSnapshot.getRepositoryName());
+                                       elasticsearchSnapshotsResponseList.add(snapshotResponse);
+
+                                       elkSnapshotsResponse.setElasticsearchSnapshots(elasticsearchSnapshotsResponseList);
+                               } else {
+                                       List<ElasticsearchSnapshotsResponse> elasticsearchSnapshotsResponseList = new ArrayList<>();
+                                       List<ElkGetSnapshotMetaData> snapshotMetaDatas = new ArrayList<>();
+                                       ElkGetSnapshotMetaData elkGetSnapshotMetaData = new ElkGetSnapshotMetaData();
+                                       elkGetSnapshotMetaData.setSnapShotId(snapshotName);
+                                       elkGetSnapshotMetaData
+                                                       .setStatus("Snapshot creation is in progress. Will take some time due size of data.");
+                                       snapshotMetaDatas.add(elkGetSnapshotMetaData);
+                                       snapshotResponse.setSnapshots(snapshotMetaDatas);
+                                       snapshotResponse.setRepositoryName(createSnapshot.getRepositoryName());
+                                       elasticsearchSnapshotsResponseList.add(snapshotResponse);
+
+                                       elkSnapshotsResponse.setElasticsearchSnapshots(elasticsearchSnapshotsResponseList);
+                               }
+                       }
+
+               }
+
+               logger.debug("Snapshot is created(true for created)");
+               return elkSnapshotsResponse;
+       }
+
+
+       @Override
+       public ElkSnapshotsResponse deleteElasticSearchSnapshot(ElkDeleteSnapshotRequest elkDeleteSnapshotRequest) {
+
+               logger.debug("Inside deleteElasticSearchSnapshot service method");
+
+               List<DeleteSnapshot> deleteSnapshots = elkDeleteSnapshotRequest.getDeleteSnapshots();
+
+               RestHighLevelClient client = restHighLevelClientConnection();
+               if (deleteSnapshots != null && !deleteSnapshots.isEmpty()) {
+
+                       ElkSnapshotsResponse elkSnapshotsResponse = new ElkSnapshotsResponse();
+                       List<ElasticsearchSnapshotsResponse> elasticsearchSnapshotsResponseList = new ArrayList<>();
+                       for (DeleteSnapshot deleteSnapshot : deleteSnapshots) {
+
+                               if (deleteSnapshot.getDelete() != null && deleteSnapshot.getDelete().equalsIgnoreCase("true")
+                                               && deleteSnapshot.getSnapShotId() != null) {
+
+                                       DeleteSnapshotRequest deleteSnapshotRequest = new DeleteSnapshotRequest(
+                                                       deleteSnapshot.getRepositoryName());
+
+                                       String[] snapshotNameId = deleteSnapshot.getSnapShotId().split("/");
+                                       String snapshotName = snapshotNameId[0];
+                                       String snapshotId = snapshotNameId[1];
+                                       logger.debug("snapshotName {}", snapshotName);
+                                       logger.debug("snapshotId {}",snapshotId);
+
+                                       deleteSnapshotRequest.snapshot(snapshotName);
+                                       deleteSnapshotRequest.masterNodeTimeout(ElkClientConstants.TIME_ONE_MINT_OUT);
+                                       AcknowledgedResponse deleteSnapshotAcknowledgedResponse;
+                                       try {
+                                               deleteSnapshotAcknowledgedResponse = client.snapshot().delete(deleteSnapshotRequest,
+                                                               RequestOptions.DEFAULT);
+                                               client.close();
+                                       } catch (IOException ex) {
+                                               logger.debug("Exception:", ex);
+                                               throw new ErrorTransport("Unable to connect Elasticserach");
+                                       }
+
+                                       ElasticsearchSnapshotsResponse elasticsearchSnapshotsResponse = new ElasticsearchSnapshotsResponse();
+                                       List<ElkGetSnapshotMetaData> snapshotMetaDatas = new ArrayList<>();
+                                       ElkGetSnapshotMetaData elkGetSnapshotMetaData = new ElkGetSnapshotMetaData();
+                                       elkGetSnapshotMetaData.setSnapShotId(deleteSnapshot.getSnapShotId());
+                                       elkGetSnapshotMetaData
+                                                       .setStatus(String.valueOf(deleteSnapshotAcknowledgedResponse.isAcknowledged()));
+                                       snapshotMetaDatas.add(elkGetSnapshotMetaData);
+                                       elasticsearchSnapshotsResponse.setSnapshots(snapshotMetaDatas);
+                                       elasticsearchSnapshotsResponse.setRepositoryName(deleteSnapshot.getRepositoryName());
+                                       elasticsearchSnapshotsResponseList.add(elasticsearchSnapshotsResponse);
+                               }
+                       }
+                       elkSnapshotsResponse.setElasticsearchSnapshots(elasticsearchSnapshotsResponseList);
+                       return elkSnapshotsResponse;
+               }
+
+               return null;
+       }       
+       
+       
+       @Override
+       public ElkSnapshotsResponse restoreElasticSearchSnapshot(ElkRestoreSnapshotRequest elkRestoreSnapshotRequest) throws IOException {
+
+               logger.debug("Inside restoreElasticSearchSnapshot service ");
+               RestHighLevelClient client = restHighLevelClientConnection();
+               logger.debug("Inside restoreElasticSearchSnapshot service 1111");
+               for (RestoreSnapshot restoreSnapshot : elkRestoreSnapshotRequest.getRestoreSnapshots()) {
+
+                       try {
+                               RestoreSnapshotRequest restoreSnapshotRequest = new RestoreSnapshotRequest(
+                                               elkRestoreSnapshotRequest.getRepositoryName(), restoreSnapshot.getSnapshotName());
+                               RestoreSnapshotResponse restoreSnapshotResponse = client.snapshot().restore(restoreSnapshotRequest, RequestOptions.DEFAULT);
+                               logger.debug("Inside restoreElasticSearchSnapshot service 5555 {}", restoreSnapshotResponse);
+                               logger.debug("Inside restoreElasticSearchSnapshot service 6666 {}", restoreSnapshotResponse.getRestoreInfo());
+                               
+                       } catch (IOException e) {
+                               logger.error("IOException ",e);
+                               throw e;
+                       }
+               }
+
+               return null;
+       }
+       
+       private ElasticsearchSnapshotsResponse getElasticsearchSnapshotDetails(
+                       ElkRepositoriesRequest elkRepositoriesRequest, String repositoryName) {
+               
+               RestHighLevelClient client = restHighLevelClientConnection();
+               GetSnapshotsRequest getSnapshotsRequest = new GetSnapshotsRequest();
+               if (elkRepositoriesRequest.getRepositoryName() != null
+                               && !elkRepositoriesRequest.getRepositoryName().isEmpty()) {
+                       getSnapshotsRequest.repository(elkRepositoriesRequest.getRepositoryName());
+               }else {
+                       getSnapshotsRequest.repository(repositoryName);
+               }
+                       
+               String[] snapshots = { "_all" };
+               getSnapshotsRequest.snapshots(snapshots);
+                getSnapshotsRequest.masterNodeTimeout(ElkClientConstants.TIME_ONE_MINT_OUT);
+               getSnapshotsRequest.verbose(true);
+               getSnapshotsRequest.ignoreUnavailable(false);
+               GetSnapshotsResponse response;
+               try {
+                       response = client.snapshot().get(getSnapshotsRequest, RequestOptions.DEFAULT);
+                       client.close();
+               } catch (IOException ex) {
+                       logger.debug("Exception:", ex);
+                       throw new ErrorTransport("Unable to connect Elasticserach");
+               }
+               logger.debug("GetSnapshotsResponse.. {}", response);
+               ElasticsearchSnapshotsResponse snapshotResponse = new ElasticsearchSnapshotsResponse();
+
+               List<ElkGetSnapshotMetaData> snapshotMetaDatas = new ArrayList<>();
+               for (SnapshotInfo snapshotInfo : response.getSnapshots()) {
+                       logger.debug("\nsnapshotId: {}", snapshotInfo.snapshotId());
+                       logger.debug("status: {}", snapshotInfo.status());
+                       logger.debug("state: {}", snapshotInfo.state());
+                       logger.debug("startTime: {}", snapshotInfo.startTime());
+                       logger.debug("endTime: {}", snapshotInfo.endTime());
+                       logger.debug("successfulShards: {}", snapshotInfo.successfulShards());
+                       ElkGetSnapshotMetaData elkGetSnapshotMetaData = new ElkGetSnapshotMetaData();
+                       elkGetSnapshotMetaData.setSnapShotId(snapshotInfo.snapshotId().toString());
+                       elkGetSnapshotMetaData.setStatus(snapshotInfo.status().toString());
+                       elkGetSnapshotMetaData.setState(snapshotInfo.state().toString());
+                       elkGetSnapshotMetaData.setStartTime(convertTime(snapshotInfo.startTime()));
+                       elkGetSnapshotMetaData.setEndTime(convertTime(snapshotInfo.endTime()));
+                       snapshotMetaDatas.add(elkGetSnapshotMetaData);
+               }
+               snapshotResponse.setSnapshots(snapshotMetaDatas);
+               return snapshotResponse;
+       }
+
+       
+       public String convertTime(long time){
+           Date date = new Date(time);
+           Format format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+           return format.format(date);
+       }
+
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/CreateSnapshot.java b/elk-client/src/main/java/org/acumos/elk/client/transport/CreateSnapshot.java
new file mode 100644 (file)
index 0000000..9ccbf55
--- /dev/null
@@ -0,0 +1,81 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class CreateSnapshot {
+
+       @ApiModelProperty(required = true, value = "ElasticStack repository name", example = "logstash")
+       private String repositoryName;
+
+       @ApiModelProperty(required = true, value = "Value ture/false is allowed", example = "true")
+       private String create;
+
+       public String getRepositoryName() {
+               return repositoryName;
+       }
+
+       public void setRepositoryName(String repositoryName) {
+               this.repositoryName = repositoryName;
+       }
+
+       public String getCreate() {
+               return create;
+       }
+
+       public void setCreate(String create) {
+               this.create = create;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((create == null) ? 0 : create.hashCode());
+               result = prime * result + ((repositoryName == null) ? 0 : repositoryName.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               CreateSnapshot other = (CreateSnapshot) obj;
+               if (create == null) {
+                       if (other.create != null)
+                               return false;
+               } else if (!create.equals(other.create))
+                       return false;
+               if (repositoryName == null) {
+                       if (other.repositoryName != null)
+                               return false;
+               } else if (!repositoryName.equals(other.repositoryName))
+                       return false;
+               return true;
+       }
+       
+       
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/DeleteSnapshot.java b/elk-client/src/main/java/org/acumos/elk/client/transport/DeleteSnapshot.java
new file mode 100644 (file)
index 0000000..9cbe9eb
--- /dev/null
@@ -0,0 +1,94 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class DeleteSnapshot {
+
+       @ApiModelProperty(required = true, value = "ElasticStack repository name", example = "logstash")
+       private String repositoryName;
+       @ApiModelProperty(value = "snapshot-2019-03-28t08-53-41", example = "snapshot-2019-03-28t08-53-41")
+       private String snapShotId;
+       @ApiModelProperty(required = true, value = "Value ture/false is allowed", example = "true")
+       private String delete;
+
+       public String getRepositoryName() {
+               return repositoryName;
+       }
+
+       public void setRepositoryName(String repositoryName) {
+               this.repositoryName = repositoryName;
+       }
+
+       public String getSnapShotId() {
+               return snapShotId;
+       }
+
+       public void setSnapShotId(String snapShotId) {
+               this.snapShotId = snapShotId;
+       }
+
+       public String getDelete() {
+               return delete;
+       }
+
+       public void setDelete(String delete) {
+               this.delete = delete;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((delete == null) ? 0 : delete.hashCode());
+               result = prime * result + ((repositoryName == null) ? 0 : repositoryName.hashCode());
+               result = prime * result + ((snapShotId == null) ? 0 : snapShotId.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               DeleteSnapshot other = (DeleteSnapshot) obj;
+               if (delete == null) {
+                       if (other.delete != null)
+                               return false;
+               } else if (!delete.equals(other.delete))
+                       return false;
+               if (repositoryName == null) {
+                       if (other.repositoryName != null)
+                               return false;
+               } else if (!repositoryName.equals(other.repositoryName))
+                       return false;
+               if (snapShotId == null) {
+                       if (other.snapShotId != null)
+                               return false;
+               } else if (!snapShotId.equals(other.snapShotId))
+                       return false;
+               return true;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ELkRepositoryMetaData.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ELkRepositoryMetaData.java
new file mode 100644 (file)
index 0000000..0b5db51
--- /dev/null
@@ -0,0 +1,95 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import org.json.simple.JSONObject;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class ELkRepositoryMetaData {
+
+       @ApiModelProperty(value = "ElasticStack repository name", example = "logstash")
+       private String name;
+       @ApiModelProperty(value = "ElasticStack repository type", example = "fs")
+       private String type;
+       private JSONObject settings = new JSONObject();
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
+
+       public JSONObject getSettings() {
+               return settings;
+       }
+
+       public void setSettings(JSONObject settings) {
+               this.settings = settings;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((name == null) ? 0 : name.hashCode());
+               result = prime * result + ((settings == null) ? 0 : settings.hashCode());
+               result = prime * result + ((type == null) ? 0 : type.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               ELkRepositoryMetaData other = (ELkRepositoryMetaData) obj;
+               if (name == null) {
+                       if (other.name != null)
+                               return false;
+               } else if (!name.equals(other.name))
+                       return false;
+               if (settings == null) {
+                       if (other.settings != null)
+                               return false;
+               } else if (!settings.equals(other.settings))
+                       return false;
+               if (type == null) {
+                       if (other.type != null)
+                               return false;
+               } else if (!type.equals(other.type))
+                       return false;
+               return true;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElasticsearchSnapshotsResponse.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElasticsearchSnapshotsResponse.java
new file mode 100644 (file)
index 0000000..6b8b7fd
--- /dev/null
@@ -0,0 +1,83 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ElasticsearchSnapshotsResponse {
+
+       @ApiModelProperty(value = "ElasticStack repository name", example = "logstash")
+       private String repositoryName;
+
+       private List<ElkGetSnapshotMetaData> snapshots;
+
+       public String getRepositoryName() {
+               return repositoryName;
+       }
+
+       public void setRepositoryName(String repositoryName) {
+               this.repositoryName = repositoryName;
+       }
+
+       public List<ElkGetSnapshotMetaData> getSnapshots() {
+               return snapshots;
+       }
+
+       public void setSnapshots(List<ElkGetSnapshotMetaData> snapshots) {
+               this.snapshots = snapshots;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((repositoryName == null) ? 0 : repositoryName.hashCode());
+               result = prime * result + ((snapshots == null) ? 0 : snapshots.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               ElasticsearchSnapshotsResponse other = (ElasticsearchSnapshotsResponse) obj;
+               if (repositoryName == null) {
+                       if (other.repositoryName != null)
+                               return false;
+               } else if (!repositoryName.equals(other.repositoryName))
+                       return false;
+               if (snapshots == null) {
+                       if (other.snapshots != null)
+                               return false;
+               } else if (!snapshots.equals(other.snapshots))
+                       return false;
+               return true;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElkCreateSnapshotRequest.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElkCreateSnapshotRequest.java
new file mode 100644 (file)
index 0000000..79545fe
--- /dev/null
@@ -0,0 +1,50 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class ElkCreateSnapshotRequest {
+
+       @ApiModelProperty(value = "CreateSnapshot is required")
+       private List<CreateSnapshot> createSnapshots;
+
+       @ApiModelProperty(required = true, value = "Value numeric values, ideal value is between 1 to 3", example = "1")
+       private String nodeTimeout;
+
+       public List<CreateSnapshot> getCreateSnapshots() {
+               return createSnapshots;
+       }
+
+       public void setCreateSnapshots(List<CreateSnapshot> createSnapshots) {
+               this.createSnapshots = createSnapshots;
+       }
+
+       public String getNodeTimeout() {
+               return nodeTimeout;
+       }
+
+       public void setNodeTimeout(String nodeTimeout) {
+               this.nodeTimeout = nodeTimeout;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElkDeleteSnapshotRequest.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElkDeleteSnapshotRequest.java
new file mode 100644 (file)
index 0000000..b3a9920
--- /dev/null
@@ -0,0 +1,49 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class ElkDeleteSnapshotRequest {
+
+       @ApiModelProperty(value = "DeleteSnapshots is required")
+       private List<DeleteSnapshot> deleteSnapshots;
+       @ApiModelProperty(required = true, value = "Value numeric values, ideal value is between 1 to 3", example = "1")
+       private String nodeTimeout;
+
+       public List<DeleteSnapshot> getDeleteSnapshots() {
+               return deleteSnapshots;
+       }
+
+       public void setDeleteSnapshots(List<DeleteSnapshot> deleteSnapshots) {
+               this.deleteSnapshots = deleteSnapshots;
+       }
+
+       public String getNodeTimeout() {
+               return nodeTimeout;
+       }
+
+       public void setNodeTimeout(String nodeTimeout) {
+               this.nodeTimeout = nodeTimeout;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElkGetRepositoriesResponse.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElkGetRepositoriesResponse.java
new file mode 100644 (file)
index 0000000..38e7b8a
--- /dev/null
@@ -0,0 +1,36 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import java.util.List;
+
+public class ElkGetRepositoriesResponse {
+
+       private List<ELkRepositoryMetaData> repositories;
+
+       public List<ELkRepositoryMetaData> getRepositories() {
+               return repositories;
+       }
+
+       public void setRepositories(List<ELkRepositoryMetaData> repositories) {
+               this.repositories = repositories;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElkGetSnapshotMetaData.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElkGetSnapshotMetaData.java
new file mode 100644 (file)
index 0000000..8685352
--- /dev/null
@@ -0,0 +1,129 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ElkGetSnapshotMetaData {
+
+       @ApiModelProperty(value = "snapshot-2019-03-28t08-53-41", example = "snapshot-2019-03-28t08-53-41")
+       private String snapShotId;
+       @ApiModelProperty(value = "Snapshot creation is in progress. Will take some time due size of data or OK", example = "'Snapshot creation is in progress. Will take some time due size of data' or 'OK' ")
+       private String status;
+       @ApiModelProperty(value = "SUCCESS", example = "SUCCESS")
+       private String state;
+       @ApiModelProperty(value = "2019-03-28 08-53-41", example = "2019-03-28 08-53-41")
+       private String startTime;
+       @ApiModelProperty(value = "2019-03-28 08-53-41", example = "2019-03-28 08-53-41")
+       private String endTime;
+
+       public String getSnapShotId() {
+               return snapShotId;
+       }
+
+       public void setSnapShotId(String snapShotId) {
+               this.snapShotId = snapShotId;
+       }
+
+       public String getStatus() {
+               return status;
+       }
+
+       public void setStatus(String status) {
+               this.status = status;
+       }
+
+       public String getState() {
+               return state;
+       }
+
+       public void setState(String state) {
+               this.state = state;
+       }
+
+       public String getStartTime() {
+               return startTime;
+       }
+
+       public void setStartTime(String startTime) {
+               this.startTime = startTime;
+       }
+
+       public String getEndTime() {
+               return endTime;
+       }
+
+       public void setEndTime(String endTime) {
+               this.endTime = endTime;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
+               result = prime * result + ((snapShotId == null) ? 0 : snapShotId.hashCode());
+               result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
+               result = prime * result + ((state == null) ? 0 : state.hashCode());
+               result = prime * result + ((status == null) ? 0 : status.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               ElkGetSnapshotMetaData other = (ElkGetSnapshotMetaData) obj;
+               if (endTime == null) {
+                       if (other.endTime != null)
+                               return false;
+               } else if (!endTime.equals(other.endTime))
+                       return false;
+               if (snapShotId == null) {
+                       if (other.snapShotId != null)
+                               return false;
+               } else if (!snapShotId.equals(other.snapShotId))
+                       return false;
+               if (startTime == null) {
+                       if (other.startTime != null)
+                               return false;
+               } else if (!startTime.equals(other.startTime))
+                       return false;
+               if (state == null) {
+                       if (other.state != null)
+                               return false;
+               } else if (!state.equals(other.state))
+                       return false;
+               if (status == null) {
+                       if (other.status != null)
+                               return false;
+               } else if (!status.equals(other.status))
+                       return false;
+               return true;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElkRepositoriesRequest.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElkRepositoriesRequest.java
new file mode 100644 (file)
index 0000000..38ad0d9
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class ElkRepositoriesRequest {
+
+       @ApiModelProperty(required = true, value = "ElasticStack repository name", example = "logstash")
+       private String repositoryName;
+
+       @ApiModelProperty(required = true, value = "Value numeric values, ideal value is between 1 to 3", example = "1")
+       private String NodeTimeout;
+
+       public String getRepositoryName() {
+               return repositoryName;
+       }
+
+       public void setRepositoryName(String repositoryName) {
+               this.repositoryName = repositoryName;
+       }
+
+       public String getNodeTimeout() {
+               return NodeTimeout;
+       }
+
+       public void setNodeTimeout(String nodeTimeout) {
+               NodeTimeout = nodeTimeout;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElkRestoreSnapshotRequest.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElkRestoreSnapshotRequest.java
new file mode 100644 (file)
index 0000000..41f97b2
--- /dev/null
@@ -0,0 +1,61 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class ElkRestoreSnapshotRequest {
+
+       @ApiModelProperty(required = true, value = "ElasticStack repository name", example = "logstash")
+       private String repositoryName;
+
+       @ApiModelProperty(value = "RestoreSnapshot is required")
+       private List<RestoreSnapshot> restoreSnapshots;
+
+       @ApiModelProperty(required = true, value = "Value numeric values, ideal value is between 1 to 3", example = "1")
+       private String nodeTimeout;
+
+       public String getRepositoryName() {
+               return repositoryName;
+       }
+
+       public void setRepositoryName(String repositoryName) {
+               this.repositoryName = repositoryName;
+       }
+
+       public List<RestoreSnapshot> getRestoreSnapshots() {
+               return restoreSnapshots;
+       }
+
+       public void setRestoreSnapshots(List<RestoreSnapshot> restoreSnapshots) {
+               this.restoreSnapshots = restoreSnapshots;
+       }
+
+       public String getNodeTimeout() {
+               return nodeTimeout;
+       }
+
+       public void setNodeTimeout(String nodeTimeout) {
+               this.nodeTimeout = nodeTimeout;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ElkSnapshotsResponse.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ElkSnapshotsResponse.java
new file mode 100644 (file)
index 0000000..32f3967
--- /dev/null
@@ -0,0 +1,36 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import java.util.List;
+
+public class ElkSnapshotsResponse {
+
+       private List<ElasticsearchSnapshotsResponse> elasticsearchSnapshots;
+
+       public List<ElasticsearchSnapshotsResponse> getElasticsearchSnapshots() {
+               return elasticsearchSnapshots;
+       }
+
+       public void setElasticsearchSnapshots(List<ElasticsearchSnapshotsResponse> elasticsearchSnapshots) {
+               this.elasticsearchSnapshots = elasticsearchSnapshots;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ErrorDetails.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ErrorDetails.java
new file mode 100644 (file)
index 0000000..deb28e7
--- /dev/null
@@ -0,0 +1,60 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+import java.util.Date;
+
+public class ErrorDetails {
+       private Date timestamp;
+       private String message;
+       private String details;
+
+       public ErrorDetails(Date timestamp, String message, String details) {
+               super();
+               this.timestamp = timestamp;
+               this.message = message;
+               this.details = details;
+       }
+
+       public Date getTimestamp() {
+               return timestamp;
+       }
+
+       public void setTimestamp(Date timestamp) {
+               this.timestamp = timestamp;
+       }
+
+       public String getMessage() {
+               return message;
+       }
+
+       public void setMessage(String message) {
+               this.message = message;
+       }
+
+       public String getDetails() {
+               return details;
+       }
+
+       public void setDetails(String details) {
+               this.details = details;
+       }
+
+}
\ No newline at end of file
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/ErrorTransport.java b/elk-client/src/main/java/org/acumos/elk/client/transport/ErrorTransport.java
new file mode 100644 (file)
index 0000000..b2d3a91
--- /dev/null
@@ -0,0 +1,31 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+/**
+ * Model for message returned on failure, to be serialized as JSON.
+ */
+public class ErrorTransport extends RuntimeException {
+
+       public ErrorTransport(String exception) {
+               super(exception);
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/transport/RestoreSnapshot.java b/elk-client/src/main/java/org/acumos/elk/client/transport/RestoreSnapshot.java
new file mode 100644 (file)
index 0000000..d13a75a
--- /dev/null
@@ -0,0 +1,59 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.transport;
+
+public class RestoreSnapshot {
+
+       private String snapshotName;
+
+       public String getSnapshotName() {
+               return snapshotName;
+       }
+
+       public void setSnapshotName(String snapshotName) {
+               this.snapshotName = snapshotName;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((snapshotName == null) ? 0 : snapshotName.hashCode());
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               RestoreSnapshot other = (RestoreSnapshot) obj;
+               if (snapshotName == null) {
+                       if (other.snapshotName != null)
+                               return false;
+               } else if (!snapshotName.equals(other.snapshotName))
+                       return false;
+               return true;
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/client/utils/ELKClientConstants.java b/elk-client/src/main/java/org/acumos/elk/client/utils/ELKClientConstants.java
new file mode 100644 (file)
index 0000000..c233ad7
--- /dev/null
@@ -0,0 +1,40 @@
+/*-
+ * ===============LICENSE_START=======================================================
+ * Acumos
+ * ===================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+ * ===================================================================================
+ * This Acumos software file is distributed by AT&T and Tech Mahindra
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *  
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ * This file 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.
+ * ===============LICENSE_END=========================================================
+ */
+package org.acumos.elk.client.utils;
+
+public final class ElkClientConstants {
+
+       public static final String APPLICATION_JSON = "application/json";
+       public static final String ELASTICSEARCH_GET_ALL_SNAPSHOT = "/all/snapshot";
+
+       public static final String GET_ALL_REPOSITORIES = "/all/repositories";
+       public static final String SNAPSHOT_CREATE_REPOSITORY = "/create/repositories";
+       public static final String SNAPSHOT_DELETE_REPOSITORY_REQUEST = "/delete/repositories";
+
+       public static final String GET_ALL_SNAPSHOTS = "/all/snapshot";
+       public static final String CREATE_SNAPSHOT_REQUEST = "/create/snapshot";
+       public static final String DELETE_SNAPSHOT_REQUEST = "/delete/snapshot";
+       public static final String RESTORE_SNAPSHOT_REQUEST = "/restore/snapshot";
+
+       public static final String TRUE = "true";
+       public static final String TIME_ONE_MINT_OUT = "1m";
+       public static final String TIME_TWO_MINT_OUT = "2m";
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/logging/ACUMOSLogConstants.java b/elk-client/src/main/java/org/acumos/elk/logging/ACUMOSLogConstants.java
new file mode 100644 (file)
index 0000000..1bdf86d
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+===============LICENSE_START=======================================================
+Acumos
+===================================================================================
+Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+===================================================================================
+This Acumos software file is distributed by AT&T and Tech Mahindra
+under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+          http://www.apache.org/licenses/LICENSE-2.0
+This file 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.
+===============LICENSE_END=========================================================
+*/
+package org.acumos.elk.logging;
+
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+import org.slf4j.MDC;
+
+
+/**
+* Constants for standard ACUMOS headers, MDCs, etc.
+*
+*/
+public final class ACUMOSLogConstants {
+
+       /**
+        * Hide and forbid construction.
+        */
+       private ACUMOSLogConstants() {
+               throw new UnsupportedOperationException();
+       }
+
+       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       //
+       // Inner classes.
+       //
+       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+       /**
+        * Marker constants.
+        */
+       public static final class Markers {
+
+               /** Marker reporting invocation. */
+               public static final Marker INVOKE = MarkerFactory.getMarker("INVOKE");
+
+               /** Marker reporting invocation. */
+               public static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE_RETURN");
+
+               /** Marker reporting synchronous invocation. */
+               public static final Marker INVOKE_SYNCHRONOUS = build("INVOKE", "SYNCHRONOUS");
+
+               /** Marker reporting asynchronous invocation. */
+               public static final Marker INVOKE_ASYNCHRONOUS = build("INVOKE", "ASYNCHRONOUS");
+
+               /** Marker reporting entry into a component. */
+               public static final Marker ENTRY = MarkerFactory.getMarker("ENTRY");
+
+               /** Marker reporting exit from a component. */
+               public static final Marker EXIT = MarkerFactory.getMarker("EXIT");
+
+               /**
+                * Build nested, detached marker.
+                * 
+                * @param m1
+                *            top token.
+                * @param m2
+                *            sub-token.
+                * @return detached Marker.
+                */
+               private static Marker build(final String m1, final String m2) {
+                       final Marker marker = MarkerFactory.getDetachedMarker(m1);
+                       marker.add(MarkerFactory.getDetachedMarker(m2));
+                       return marker;
+               }
+
+               /**
+                * Hide and forbid construction.
+                */
+               private Markers() {
+                       throw new UnsupportedOperationException();
+               }
+       }
+
+       /**
+        * MDC name constants.
+        */
+       public static final class MDCs {
+
+               // Tracing. ////////////////////////////////////////////////////////////
+
+               /** MDC correlating messages for a logical transaction. */
+               public static final String REQUEST_ID = "RequestID";
+
+               /** MDC recording target service. */
+               public static final String TARGET_SERVICE_NAME = "TargetServiceName";
+
+               /** MDC recording target entity. */
+               public static final String TARGET_ENTITY = "TargetEntity";
+
+               // Network. ////////////////////////////////////////////////////////////
+
+               /** MDC recording caller address. */
+               public static final String CLIENT_IP_ADDRESS = "ClientIPAddress";
+
+               /** MDC recording server address. */
+               public static final String SERVER_FQDN = "ServerFQDN";
+
+               /** MDC reporting outcome code. */
+               public static final String RESPONSE_CODE = "ResponseCode";
+
+               /** MDC reporting outcome description. */
+               public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
+
+               /** MDC reporting outcome error level. */
+               public static final String RESPONSE_SEVERITY = "Severity";
+
+               /** MDC reporting outcome status of the request. */
+               public static final String STATUS_CODE = "StatusCode";
+
+               // Unsorted. ///////////////////////////////////////////////////////////
+
+               /**
+                * Hide and forbid construction.
+                */
+               private MDCs() {
+                       throw new UnsupportedOperationException();
+               }
+       }
+
+       /**
+        * Header name constants.
+        */
+       public static final class Headers {
+
+               /** HTTP X-ACUMOS-RequestID header. */
+               public static final String REQUEST_ID = "X-ACUMOS-RequestID";
+
+               /**
+                * Hide and forbid construction.
+                */
+               private Headers() {
+                       throw new UnsupportedOperationException();
+               }
+       }
+
+       /**
+        * Overrideable method to set MDCs based on property values.
+        */
+       public static void setDefaultMDCs() {
+               MDC.put(MDCs.RESPONSE_SEVERITY, ResponseSeverity.DEBUG.toString());
+               MDC.put(MDCs.STATUS_CODE, ResponseStatus.INPROGRESS.toString());
+       }
+
+       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+       //
+       // Enums.
+       //
+       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+       /**
+        * Response success or not, for setting StatusCode.
+        */
+       public enum ResponseStatus {
+               
+               COMPLETED,
+               ERROR,
+               INPROGRESS
+       }
+
+       /**
+        * Response of log level, for setting Severity.
+        */
+       public enum ResponseSeverity {
+
+               INFO,
+               ERROR,
+               TRACE,
+               DEBUG,
+               WARN,
+               FATAL
+       }
+
+       /**
+        * Synchronous or asynchronous execution, for setting invocation marker.
+        */
+       public enum InvocationMode {
+
+               /** Synchronous, blocking. */
+               SYNCHRONOUS("SYNCHRONOUS", Markers.INVOKE_SYNCHRONOUS),
+
+               /** Asynchronous, non-blocking. */
+               ASYNCHRONOUS("ASYNCHRONOUS", Markers.INVOKE_ASYNCHRONOUS);
+
+               /** Enum value. */
+               private String mString;
+
+               /** Corresponding marker. */
+               private Marker mMarker;
+
+               /**
+                * Construct enum.
+                *
+                * @param s
+                *            enum value.
+                * @param m
+                *            corresponding Marker.
+                */
+               InvocationMode(final String s, final Marker m) {
+                       this.mString = s;
+                       this.mMarker = m;
+               }
+
+               /**
+                * Get Marker for enum.
+                *
+                * @return Marker.
+                */
+               public Marker getMarker() {
+                       return this.mMarker;
+               }
+
+               @Override
+               public String toString() {
+                       return this.mString;
+               }
+       }
+
+}
diff --git a/elk-client/src/main/java/org/acumos/elk/logging/LogConfig.java b/elk-client/src/main/java/org/acumos/elk/logging/LogConfig.java
new file mode 100644 (file)
index 0000000..b537629
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+===============LICENSE_START=======================================================
+Acumos
+===================================================================================
+Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+===================================================================================
+This Acumos software file is distributed by AT&T and Tech Mahindra
+under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+          http://www.apache.org/licenses/LICENSE-2.0
+This file 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.
+===============LICENSE_END=========================================================
+*/
+package org.acumos.elk.logging;
+
+import java.net.InetAddress;
+import java.util.UUID;
+
+import org.acumos.elk.logging.ACUMOSLogConstants.MDCs;
+import org.slf4j.MDC;
+
+public class LogConfig {
+       public static void setEnteringMDCs(String targetEntry,String targetService) throws Exception{
+               String hostname="";
+        String ip="";
+               ACUMOSLogConstants.setDefaultMDCs();
+               String requestId = UUID.randomUUID().toString();
+               String finalHostIP=getHostDetails();
+               if(finalHostIP!=null) {
+                       String hostIpArr[]=finalHostIP.split("/");
+                       hostname=hostIpArr[0];
+                       ip=hostIpArr[1];
+               }
+               MDC.put(MDCs.REQUEST_ID, requestId);            
+               MDC.put(MDCs.TARGET_ENTITY, targetEntry);
+               MDC.put(MDCs.TARGET_SERVICE_NAME, targetService);
+               MDC.put(MDCs.CLIENT_IP_ADDRESS, ip);
+               MDC.put(MDCs.SERVER_FQDN, hostname);
+
+               
+       }
+       public static void clearMDCDetails() {
+               MDC.clear();
+       }
+       
+       public static String getHostDetails()throws Exception {
+               InetAddress ip;
+        String hostname=null;
+        String ipStr=null;
+        String finalHostIP=null;
+        
+            ip = InetAddress.getLocalHost();
+            hostname = ip.getHostName();
+            ipStr=ip.getHostAddress();
+            if(hostname!=null && ipStr!=null) {
+               finalHostIP=hostname+"/"+ipStr;
+            }
+        return finalHostIP;
+       }
+}
diff --git a/elk-client/src/main/resources/application.properties b/elk-client/src/main/resources/application.properties
new file mode 100644 (file)
index 0000000..c6ee806
--- /dev/null
@@ -0,0 +1,22 @@
+###
+# ===============LICENSE_START=======================================================
+# Acumos
+# ===================================================================================
+# Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
+# ===================================================================================
+# This Acumos software file is distributed by AT&T and Tech Mahindra
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#  
+#      http://www.apache.org/licenses/LICENSE-2.0
+#  
+# This file 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.
+# ===============LICENSE_END=========================================================
+###
+server.port=9006
+# REST endpoint configuration; i.e., where this server listens
+server.servlet.context-path=/elkclient
diff --git a/elk-client/src/main/resources/logback.xml b/elk-client/src/main/resources/logback.xml
new file mode 100644 (file)
index 0000000..d01e2d0
--- /dev/null
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ===============LICENSE_START======================================================= 
+       Acumos =================================================================================== 
+       Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights 
+       reserved. =================================================================================== 
+       This Acumos software file is distributed by AT&T and Tech Mahindra under 
+       the Apache License, Version 2.0 (the "License"); you may not use this file 
+       except in compliance with the License. You may obtain a copy of the License 
+       at http://www.apache.org/licenses/LICENSE-2.0 This file 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. ===============LICENSE_END========================================================= -->
+<configuration scan="true" scanPeriod="3 seconds" debug="false">
+
+       <!-- gather files in a subdirectory - usually a volume in docker -->
+       <property name="logDirPrefix" value="logs/platform-oam" />
+
+       <!-- component name is log file basename -->
+       <property name="componentName" value="elk-client"></property>
+
+       <!-- The directories where logs are written -->
+       <property name="logDirectory" value="${logDirPrefix}/${componentName}" />
+
+       <!-- Based on https://wiki.acumos.org/display/OAM/Acumos+Log+Standards -->
+       <property name="LogTimestamp"
+               value="%d{&quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&quot;, UTC}" />
+       <property name="Level" value="%.-5level" />
+       <property name="Logger" value="%logger" />
+       <property name="Mdc"
+               value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n','\\\\n'}" />
+       <property name="Marker"
+               value="%replace(%replace(%marker){'\t','\\\\t'}){'\n','\\\\n'}" />
+       <property name="Thread" value="%thread" />
+       <property name="Message"
+               value="%replace(%replace(%msg){'\t','\\\\t'}){'\n','\\\\n'}" />
+       <!-- Gather exception stack trace with no linebreaks -->
+       <property name="Exception"
+               value="%replace(%replace(%ex){'\t', '\\\\t'}){'\n','\\\\n'}" />
+
+
+       <!-- Use %nopexception to disable Logback default behavior of appending 
+               %ex -->
+
+       <property name="singleLineBoreasPattern"
+               value="%nopexception${LogTimestamp}\t${Thread}\t${Level}\t${Logger}\t${Marker}\t${Mdc}\t${Message}\t${Exception}%n" />
+       <property name="multiLineBoreasPattern"
+               value="${LogTimestamp}\t${Thread}\t${Level}\t${Logger}\t${Marker}\t${Mdc}\t%msg\t%ex%n" />
+
+       <!-- Uncomment below code for filter if need to show events with level WARN 
+               or above on the console (docker log) -->
+       <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+               <!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>WARN</level> 
+                       </filter> -->
+               <encoder>
+                       <pattern>${multiLineBoreasPattern}</pattern>
+               </encoder>
+       </appender>
+
+       <!-- Show all events in the rolling log file -->
+       <appender name="file-rolling"
+               class="ch.qos.logback.core.rolling.RollingFileAppender">
+               <file>${logDirectory}/${componentName}.log</file>
+               <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+                       <!-- daily rollover -->
+                       <fileNamePattern>${logDirectory}/${componentName}.%d{yyyy-MM-dd}.log.zip
+                       </fileNamePattern>
+                       <!-- keep 30 days' worth of history capped at 3GB total size -->
+                       <maxHistory>30</maxHistory>
+                       <totalSizeCap>3GB</totalSizeCap>
+               </rollingPolicy>
+               <encoder>
+                       <pattern>${singleLineBoreasPattern}</pattern>
+               </encoder>
+       </appender>
+       <appender name="file-async" class="ch.qos.logback.classic.AsyncAppender">
+               <queueSize>256</queueSize>
+               <includeCallerData>true</includeCallerData>
+               <appender-ref ref="file-rolling" />
+       </appender>
+
+       <!-- The root level is the default for all loggers, NOT a filter on any 
+               appender. This level can be set with property logging.level.root=LEVEL. -->
+       <root level="DEBUG">
+               <appender-ref ref="file-async" />
+               <appender-ref ref="STDOUT" />
+       </root>
+</configuration>
index 1297ad2..8652b96 100644 (file)
 # Be verbose
 set -x
 
+export ACUMOS_ELK_ELASTICSEARCH_HOST=elasticsearch-hostname
 export ACUMOS_ELK_ELASTICSEARCH_PORT=9200
 export ACUMOS_ELK_NODE_PORT=9300
 export ACUMOS_ELK_LOGSTASH_PORT=5000
 export ACUMOS_ELK_KIBANA_PORT=5601
+export ACUMOS_ELK_CLIENT_PORT=9600
+
+#Elk client schedule cron job for snapshot creation.
+export ELK_CLIENT_CRONSCHEDULE_CREATESNAPSHOT_TIME=* 1 * * * *
 
 # Java heap size
 export ACUMOS_ELK_ES_JAVA_HEAP_MIN_SIZE=4g
@@ -46,6 +51,7 @@ export NEXUS3_STAGING_REGISTRY_LF=nexus3.acumos.org:10004
 export NEXUS3_RELEASE_REGISTRY_LF=nexus3.acumos.org:10002
 
 # Images
-export ELASTICSEARCH_IMAGE=acumos-elasticsearch:2.0.0
-export LOGSTASH_IMAGE=acumos-logstash:2.0.0
-export KIBANA_IMAGE=acumos-kibana:2.0.0
+export ELASTICSEARCH_IMAGE=acumos-elasticsearch:2.0.8
+export LOGSTASH_IMAGE=acumos-logstash:2.0.8
+export KIBANA_IMAGE=acumos-kibana:2.0.8
+export ELK_CLIENT=2.0.8
index 533ae40..9b158c2 100644 (file)
@@ -64,6 +64,29 @@ services:
     depends_on:
       - elasticsearch
 
+  elk-client:
+      image: ${NEXUS3_RELEASE_REGISTRY_LF}/${ELK_CLIENT}
+      environment:
+          SPRING_APPLICATION_JSON: '{
+              "server" : { 
+                   "port" : 9006
+               },
+               "elk" : {
+                   "host" : {
+                       "url":${ACUMOS_ELK_ELASTICSEARCH_HOST}
+                   },
+                   "elasticssearch" : {
+                               "port":${ACUMOS_ELK_ELASTICSEARCH_PORT}
+                           },
+                   "cronschedule": {
+                       "createsnapshot":{
+                           "time":${ELK_CLIENT_CRONSCHEDULE_CREATESNAPSHOT_TIME}
+                       }
+                   }
+               }
+          }'
+      ports:
+          - ${ACUMOS_ELK_CLIENT_PORT}:9006
 
 networks:
   elk:
index afd9f61..6af9433 100644 (file)
@@ -22,6 +22,7 @@
 cluster.name: "docker-cluster"
 network.host: 0.0.0.0
 path.data: /usr/share/elasticsearch/data
+path.repo: ["/backup"]
 # minimum_master_nodes need to be explicitly set when bound on a public IP
 # set to 1 to allow single node clusters
 # Details: https://github.com/elastic/elasticsearch/pull/17288
index de189e7..45a5a7f 100644 (file)
@@ -25,7 +25,7 @@
         <!-- docker image name -->
         <artifactId>acumos-elasticsearch</artifactId>
         <!-- docker tag -->
-        <version>2.0.7-SNAPSHOT</version>
+        <version>2.0.8-SNAPSHOT</version>
 </project>
 
 
index 6325ad1..5b852db 100644 (file)
@@ -25,7 +25,7 @@
         <!-- docker image name -->
         <artifactId>acumos-kibana</artifactId>
         <!-- docker tag -->
-        <version>2.0.7-SNAPSHOT</version>
+        <version>2.0.8-SNAPSHOT</version>
 </project>
 
 
index 149420e..8dd20c4 100644 (file)
@@ -25,5 +25,5 @@
         <!-- docker image name -->
         <artifactId>acumos-logstash</artifactId>
         <!-- docker tag -->
-        <version>2.0.7-SNAPSHOT</version>
+        <version>2.0.8-SNAPSHOT</version>
 </project>
index 9e3ca43..8219b43 100644 (file)
@@ -25,7 +25,7 @@
         <!-- docker image name -->
         <artifactId>acumos-filebeat</artifactId>
         <!-- docker tag -->
-        <version>2.0.7-SNAPSHOT</version>
+        <version>2.0.8-SNAPSHOT</version>
 </project>
 
 
index c27e212..2136c6a 100644 (file)
@@ -25,7 +25,7 @@
         <!-- docker image name -->
         <artifactId>acumos-metricbeat</artifactId>
         <!-- docker tag -->
-        <version>2.0.7-SNAPSHOT</version>
+        <version>2.0.8-SNAPSHOT</version>
 </project>