Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metrics #9

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ folderPath: /opt/takipi-storage/storage
maxUsedStoragePercentage: 0.95
enableCors: true
corsOrigins: "*"
metricFrequencySeconds: 60

server:
# softNofileLimit: 1000
Expand All @@ -18,6 +19,9 @@ server:
adminConnectors:
- type: http
port: 8081

requestLog:
appenders: []

# Logging settings.
logging:
Expand All @@ -27,8 +31,15 @@ logging:

# Logger-specific levels.
loggers:

com.takipi: DEBUG

appenders:
- type: console
logFormat: "[%d{dd-MM HH:mm:ss.SSS}] %-5level - %msg {%logger{0}} [%thread] %n"
- type: file
logFormat: "[%d{dd-MM HH:mm:ss.SSS}] %-5level - %msg {%logger{0}} [%thread] %n"
threshold: INFO
currentLogFilename: ./log.log
archive: true
archivedLogFilenamePattern: ./archived-logs/logs-%d.log
archivedFileCount: 2
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ public class TakipiStorageConfiguration extends Configuration {
@Max(1)
private double maxUsedStoragePercentage = 0.9;

private boolean enableCors;
private boolean enableCors = false;

private int metricFrequencySeconds = 0;

@NotEmpty
private String corsOrigins;

@JsonProperty
public int getMetricFrequencySeconds() {
return metricFrequencySeconds;
}

@JsonProperty
public boolean isEnableCors() {
return enableCors;
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/com/takipi/oss/storage/TakipiStorageMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.EnumSet;

import javax.servlet.DispatcherType;
Expand All @@ -20,8 +23,13 @@
import com.takipi.oss.storage.resources.fs.JsonMultiFetchStorageResource;
import com.takipi.oss.storage.resources.fs.JsonSimpleFetchStorageResource;
import com.takipi.oss.storage.resources.fs.JsonSimpleSearchStorageResource;
import com.takipi.oss.storage.metric.LoggerStorageMetric;
import com.takipi.oss.storage.metric.NopStorageMetric;
import com.takipi.oss.storage.metric.StorageMetric;

public class TakipiStorageMain extends Application<TakipiStorageConfiguration> {
private static final Logger logger = LoggerFactory.getLogger(TakipiStorageMain.class);

public static void main(String[] args) throws Exception {
new TakipiStorageMain().run(args);
}
Expand All @@ -42,17 +50,27 @@ public void run(TakipiStorageConfiguration configuration, Environment environmen
enableCors(configuration, environment);
}

environment.jersey().register(new BinaryStorageResource(configuration));
StorageMetric storageMetric;

if (configuration.getMetricFrequencySeconds() == 0) {
logger.info("Creating NOP storage metric");
storageMetric = new NopStorageMetric();
} else {
logger.info("Creating storage metric (freq: {})", configuration.getMetricFrequencySeconds());
storageMetric = new LoggerStorageMetric(configuration.getMetricFrequencySeconds());
}

environment.jersey().register(new BinaryStorageResource(configuration, storageMetric));
environment.jersey().register(new JsonMultiFetchStorageResource(configuration));
environment.jersey().register(new JsonMultiDeleteStorageResource(configuration));

environment.jersey().register(new JsonSimpleFetchStorageResource(configuration));
environment.jersey().register(new JsonSimpleSearchStorageResource(configuration));

environment.jersey().register(new PingStorageResource());
environment.jersey().register(new TreeStorageResource(configuration));
environment.jersey().register(new StatusStorageResource(configuration));

environment.healthChecks().register("filesystem", new FilesystemHealthCheck(configuration));
}

Expand Down
Loading