Skip to content

Commit

Permalink
Refactor (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDombo authored and jbutler committed Dec 14, 2020
1 parent 1dbef8f commit 8db6425
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
java-version: 1.8
- run: rm -rf /tmp/*
continue-on-error: true
- run: rm -rf ~/.m2/repository/com/aws/iot/evergreen-kernel
continue-on-error: true
- name: Build with Maven
run: mvn -ntp -U clean verify
- name: Upload Failed Test Report
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
coverage
*.iml
bin
evergreen*.log
greengrass*.log
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Log Manager

Log Manager is a Greengrass component that manages the system as well as user component logs.
Lambda Manager is an optional internal Evergreen service that runs in the same JVM as the
[Greengrass nucleus](https://github.com/aws/aws-greengrass-kernel).
Lambda Manager is an optional internal Greengrass service that runs in the same JVM as the
[Greengrass nucleus](https://github.com/aws/aws-greengrass-nucleus).

Log Manager has two major features: **Logs Uploader** and **Disk Space Management**

Expand Down
2 changes: 1 addition & 1 deletion codestyle/IntelliJ.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
~ SPDX-License-Identifier: Apache-2.0
-->

<code_scheme name="Evergreen" version="173">
<code_scheme name="Greengrass" version="173">
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
<JavaCodeStyleSettings>
<option name="ANNOTATION_PARAMETER_WRAP" value="1" />
Expand Down
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.aws.iot</groupId>
<artifactId>greengrass-log-manager</artifactId>
<groupId>com.aws.greengrass</groupId>
<artifactId>log-manager</artifactId>
<name>greengrass-log-manager</name>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>evergreen-dev-snapshot</id>
<name>Kernel Snapshot</name>
<id>greengrass-dev-snapshot</id>
<name>Nucleus Snapshot</name>
<url>https://d10d248laylpoq.cloudfront.net</url>
</repository>
</repositories>
Expand All @@ -32,14 +33,14 @@
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.aws.iot</groupId>
<artifactId>evergreen-kernel</artifactId>
<groupId>com.aws.greengrass</groupId>
<artifactId>nucleus</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.aws.iot</groupId>
<artifactId>evergreen-kernel</artifactId>
<groupId>com.aws.greengrass</groupId>
<artifactId>nucleus</artifactId>
<version>1.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class LogManagerService extends PluginService {
/**
* Constructor.
*
* @param topics The configuration coming from the kernel.
* @param topics The configuration coming from the nucleus.
* @param uploader {@link CloudWatchLogsUploader}
* @param logProcessor {@link CloudWatchAttemptLogsProcessor}
* @param executorService {@link ExecutorService}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void GIVEN_one_component_one_file_less_than_max_WHEN_locate_throws_Servic
public void GIVEN_one_component_one_file_more_than_max_WHEN_merge_THEN_reads_partial_file()
throws IOException, ServiceLoadException {
mockDefaultGetGroups();
File file = new File(directoryPath.resolve("evergreen_test.log").toUri());
File file = new File(directoryPath.resolve("greengrass_test.log").toUri());
assertTrue(file.createNewFile());
assertTrue(file.setReadable(true));
assertTrue(file.setWritable(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public class LogManagerServiceTest extends GGServiceTestUtil {
static void setupBefore() throws IOException, InterruptedException {
LogConfig.getInstance().setLevel(Level.TRACE);
LogConfig.getInstance().setStoreType(LogStore.FILE);
LogConfig.getInstance().setStorePath(directoryPath.resolve("evergreen.log"));
LogConfig.getInstance().setStorePath(directoryPath.resolve("greengrass.log"));
for (int i = 0; i < 5; i++) {
File file = new File(directoryPath.resolve("evergreen_test_" + i + ".log").toUri());
File file = new File(directoryPath.resolve("greengrass_test_" + i + ".log").toUri());
assertTrue(file.createNewFile());
assertTrue(file.setReadable(true));
assertTrue(file.setWritable(true));
Expand All @@ -118,7 +118,7 @@ static void setupBefore() throws IOException, InterruptedException {
}
TimeUnit.SECONDS.sleep(1);
}
File currentFile = new File(directoryPath.resolve("evergreen.log").toUri());
File currentFile = new File(directoryPath.resolve("greengrass.log").toUri());
try (OutputStream currentFileOutputStream = Files.newOutputStream(currentFile.toPath())) {
currentFileOutputStream.write("TEST".getBytes(StandardCharsets.UTF_8));
}
Expand All @@ -132,7 +132,7 @@ static void cleanUpAfter() {
final File[] files = folder.listFiles();
if (files != null) {
for (final File file : files) {
if (file.getName().startsWith("evergreen") && !file.delete()) {
if (file.getName().startsWith("greengrass") && !file.delete()) {
System.err.println("Can't remove " + file.getAbsolutePath());
}
}
Expand Down Expand Up @@ -383,8 +383,8 @@ public void GIVEN_some_system_files_uploaded_and_another_partially_uploaded_WHEN
.thenReturn(configTopic);

logsUploaderService = new LogManagerService(config, mockUploader, mockMerger, executor);
File file = new File(directoryPath.resolve("evergreen_test_2.log").toUri());
File currentProcessingFile = new File(directoryPath.resolve("evergreen_test_3.log").toUri());
File file = new File(directoryPath.resolve("greengrass_test_2.log").toUri());
File currentProcessingFile = new File(directoryPath.resolve("greengrass_test_3.log").toUri());
logsUploaderService.lastComponentUploadedLogFileInstantMap.put(SYSTEM_LOGS_COMPONENT_NAME,
Instant.ofEpochMilli(file.lastModified()));
logsUploaderService.componentCurrentProcessingLogFile.put(SYSTEM_LOGS_COMPONENT_NAME,
Expand Down Expand Up @@ -576,8 +576,8 @@ public void GIVEN_a_partially_uploaded_file_but_rotated_WHEN_merger_merges_THEN_
logsUploaderService = new LogManagerService(config, mockUploader, mockMerger, executor);
startServiceOnAnotherThread();

File file = new File(directoryPath.resolve("evergreen.log_test_2").toUri());
File currentProcessingFile = new File(directoryPath.resolve("evergreen.log_test-3").toUri());
File file = new File(directoryPath.resolve("greengrass.log_test_2").toUri());
File currentProcessingFile = new File(directoryPath.resolve("greengrass.log_test-3").toUri());
logsUploaderService.lastComponentUploadedLogFileInstantMap.put(SYSTEM_LOGS_COMPONENT_NAME,
Instant.ofEpochMilli(file.lastModified()));
logsUploaderService.componentCurrentProcessingLogFile.put(SYSTEM_LOGS_COMPONENT_NAME,
Expand Down

0 comments on commit 8db6425

Please sign in to comment.