repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
cscotta/deschutes
src/main/java/com/cscotta/deschutes/input/CyclingProtobufPreReader.java
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java // public interface EventWrapper<RawInput, WrappedInput> { // // public WrappedInput wrap(RawInput raw); // // }
import com.cscotta.deschutes.api.EventWrapper; import com.google.protobuf.Parser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator;
package com.cscotta.deschutes.input; public class CyclingProtobufPreReader<ProtoType, Input> implements Iterable<Input> { final Parser<ProtoType> parser; final InputStream inputStream;
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java // public interface EventWrapper<RawInput, WrappedInput> { // // public WrappedInput wrap(RawInput raw); // // } // Path: src/main/java/com/cscotta/deschutes/input/CyclingProtobufPreReader.java import com.cscotta.deschutes.api.EventWrapper; import com.google.protobuf.Parser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; package com.cscotta.deschutes.input; public class CyclingProtobufPreReader<ProtoType, Input> implements Iterable<Input> { final Parser<ProtoType> parser; final InputStream inputStream;
final EventWrapper<ProtoType, Input> eventWrapper;
cscotta/deschutes
src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java // public interface ConcurrentRollup<Input> extends Event { // // /** // * <p>Rollup method called as events are received by a stream for // * aggregation.</p> // * // * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain // * the aggregations desired (sums, averages, histograms, and so on), and expose // * them for downstream {@link OutputListener}s to access as output. See the // * {@link ConcurrentRollup} documentation above for a sample implementation.</p> // * // * @param input An event received by a stream to be rolled up. // */ // public abstract void rollup(Input input); // // public long getTimestamp(); // } // // Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java // public interface RollupFactory<T> { // // public ConcurrentRollup<T> buildRollup(long timestamp); // // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java // public class RequestRollup implements ConcurrentRollup<RequestEvent> { // // private final long timestamp; // // public RequestRollup(long timestamp) { // this.timestamp = timestamp; // } // // private final AtomicLong requestCount = new AtomicLong(0); // private final AtomicLong totalRequestBytes = new AtomicLong(0); // private final AtomicLong totalResponseBytes = new AtomicLong(0); // // private final Histogram requestBytesHisto = new Histogram(new UniformReservoir()); // private final Histogram responseBytesHisto = new Histogram(new UniformReservoir()); // // private final Histogram handshakeUsec = new Histogram(new UniformReservoir()); // private final Histogram usecToFirstByte = new Histogram(new UniformReservoir()); // private final Histogram usecTotal = new Histogram(new UniformReservoir()); // // // public long getRequestCount() { return requestCount.get(); } // public long getTotalRequestBytes() { return totalRequestBytes.get(); } // public long getTotalResponseBytes() { return totalResponseBytes.get(); } // // public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); } // public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); } // // public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); } // public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); } // public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); } // // @Override // public void rollup(RequestEvent request) { // requestCount.incrementAndGet(); // totalRequestBytes.addAndGet(request.getRequestBytes()); // totalResponseBytes.addAndGet(request.getResponseBytes()); // requestBytesHisto.update(request.getRequestBytes()); // responseBytesHisto.update(request.getResponseBytes()); // handshakeUsec.update(request.getHandshakeUsec()); // usecToFirstByte.update(request.getUsecToFirstByte()); // usecTotal.update(request.getUsecTotal()); // } // // @Override // public long getTimestamp() { // return this.timestamp; // } // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java // public class RequestEvent implements Event { // // private final Request request; // // public RequestEvent(Request request) { // this.request = request; // } // // @Override // public long getTimestamp() { // return request.getTimestamp(); // } // // public int getUserId() { // return request.getUserId(); // } // // public int getClientIp() { // return request.getClientIp(); // } // // public int getServerIp() { // return request.getServerIp(); // } // // public OperationType getOperationType() { // return request.getOperationType(); // } // // public Protocol getProtocol() { // return request.getProtocol(); // } // // public int getResponseCode() { // return request.getResponseCode(); // } // // public String getUri() { // return request.getUri(); // } // // public int getRequestBytes() { // return request.getRequestBytes(); // } // // public int getResponseBytes() { // return request.getResponseBytes(); // } // // public long getHandshakeUsec() { // return request.getHandshakeUsec(); // } // // public long getUsecToFirstByte() { // return request.getUsecToFirstByte(); // } // // public long getUsecTotal() { // return request.getUsecTotal(); // } // // public String getUserAgent() { // return request.getUserAgent(); // } // // public String getLocale() { // return request.getLocale(); // } // // public String getReferrer() { // return request.getReferrer(); // } // // @Override // public String toString() { // return request.toString(); // } // // }
import com.cscotta.deschutes.api.ConcurrentRollup; import com.cscotta.deschutes.api.RollupFactory; import com.cscotta.deschutes.example.requests.RequestRollup; import com.cscotta.deschutes.example.requests.RequestEvent;
package com.cscotta.deschutes.example.requests; public class RequestRollups { public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() { @Override
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java // public interface ConcurrentRollup<Input> extends Event { // // /** // * <p>Rollup method called as events are received by a stream for // * aggregation.</p> // * // * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain // * the aggregations desired (sums, averages, histograms, and so on), and expose // * them for downstream {@link OutputListener}s to access as output. See the // * {@link ConcurrentRollup} documentation above for a sample implementation.</p> // * // * @param input An event received by a stream to be rolled up. // */ // public abstract void rollup(Input input); // // public long getTimestamp(); // } // // Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java // public interface RollupFactory<T> { // // public ConcurrentRollup<T> buildRollup(long timestamp); // // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java // public class RequestRollup implements ConcurrentRollup<RequestEvent> { // // private final long timestamp; // // public RequestRollup(long timestamp) { // this.timestamp = timestamp; // } // // private final AtomicLong requestCount = new AtomicLong(0); // private final AtomicLong totalRequestBytes = new AtomicLong(0); // private final AtomicLong totalResponseBytes = new AtomicLong(0); // // private final Histogram requestBytesHisto = new Histogram(new UniformReservoir()); // private final Histogram responseBytesHisto = new Histogram(new UniformReservoir()); // // private final Histogram handshakeUsec = new Histogram(new UniformReservoir()); // private final Histogram usecToFirstByte = new Histogram(new UniformReservoir()); // private final Histogram usecTotal = new Histogram(new UniformReservoir()); // // // public long getRequestCount() { return requestCount.get(); } // public long getTotalRequestBytes() { return totalRequestBytes.get(); } // public long getTotalResponseBytes() { return totalResponseBytes.get(); } // // public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); } // public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); } // // public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); } // public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); } // public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); } // // @Override // public void rollup(RequestEvent request) { // requestCount.incrementAndGet(); // totalRequestBytes.addAndGet(request.getRequestBytes()); // totalResponseBytes.addAndGet(request.getResponseBytes()); // requestBytesHisto.update(request.getRequestBytes()); // responseBytesHisto.update(request.getResponseBytes()); // handshakeUsec.update(request.getHandshakeUsec()); // usecToFirstByte.update(request.getUsecToFirstByte()); // usecTotal.update(request.getUsecTotal()); // } // // @Override // public long getTimestamp() { // return this.timestamp; // } // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java // public class RequestEvent implements Event { // // private final Request request; // // public RequestEvent(Request request) { // this.request = request; // } // // @Override // public long getTimestamp() { // return request.getTimestamp(); // } // // public int getUserId() { // return request.getUserId(); // } // // public int getClientIp() { // return request.getClientIp(); // } // // public int getServerIp() { // return request.getServerIp(); // } // // public OperationType getOperationType() { // return request.getOperationType(); // } // // public Protocol getProtocol() { // return request.getProtocol(); // } // // public int getResponseCode() { // return request.getResponseCode(); // } // // public String getUri() { // return request.getUri(); // } // // public int getRequestBytes() { // return request.getRequestBytes(); // } // // public int getResponseBytes() { // return request.getResponseBytes(); // } // // public long getHandshakeUsec() { // return request.getHandshakeUsec(); // } // // public long getUsecToFirstByte() { // return request.getUsecToFirstByte(); // } // // public long getUsecTotal() { // return request.getUsecTotal(); // } // // public String getUserAgent() { // return request.getUserAgent(); // } // // public String getLocale() { // return request.getLocale(); // } // // public String getReferrer() { // return request.getReferrer(); // } // // @Override // public String toString() { // return request.toString(); // } // // } // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java import com.cscotta.deschutes.api.ConcurrentRollup; import com.cscotta.deschutes.api.RollupFactory; import com.cscotta.deschutes.example.requests.RequestRollup; import com.cscotta.deschutes.example.requests.RequestEvent; package com.cscotta.deschutes.example.requests; public class RequestRollups { public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() { @Override
public ConcurrentRollup<RequestEvent> buildRollup(long timestamp) {
cscotta/deschutes
src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java // public interface ConcurrentRollup<Input> extends Event { // // /** // * <p>Rollup method called as events are received by a stream for // * aggregation.</p> // * // * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain // * the aggregations desired (sums, averages, histograms, and so on), and expose // * them for downstream {@link OutputListener}s to access as output. See the // * {@link ConcurrentRollup} documentation above for a sample implementation.</p> // * // * @param input An event received by a stream to be rolled up. // */ // public abstract void rollup(Input input); // // public long getTimestamp(); // } // // Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java // public interface RollupFactory<T> { // // public ConcurrentRollup<T> buildRollup(long timestamp); // // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java // public class RequestRollup implements ConcurrentRollup<RequestEvent> { // // private final long timestamp; // // public RequestRollup(long timestamp) { // this.timestamp = timestamp; // } // // private final AtomicLong requestCount = new AtomicLong(0); // private final AtomicLong totalRequestBytes = new AtomicLong(0); // private final AtomicLong totalResponseBytes = new AtomicLong(0); // // private final Histogram requestBytesHisto = new Histogram(new UniformReservoir()); // private final Histogram responseBytesHisto = new Histogram(new UniformReservoir()); // // private final Histogram handshakeUsec = new Histogram(new UniformReservoir()); // private final Histogram usecToFirstByte = new Histogram(new UniformReservoir()); // private final Histogram usecTotal = new Histogram(new UniformReservoir()); // // // public long getRequestCount() { return requestCount.get(); } // public long getTotalRequestBytes() { return totalRequestBytes.get(); } // public long getTotalResponseBytes() { return totalResponseBytes.get(); } // // public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); } // public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); } // // public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); } // public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); } // public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); } // // @Override // public void rollup(RequestEvent request) { // requestCount.incrementAndGet(); // totalRequestBytes.addAndGet(request.getRequestBytes()); // totalResponseBytes.addAndGet(request.getResponseBytes()); // requestBytesHisto.update(request.getRequestBytes()); // responseBytesHisto.update(request.getResponseBytes()); // handshakeUsec.update(request.getHandshakeUsec()); // usecToFirstByte.update(request.getUsecToFirstByte()); // usecTotal.update(request.getUsecTotal()); // } // // @Override // public long getTimestamp() { // return this.timestamp; // } // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java // public class RequestEvent implements Event { // // private final Request request; // // public RequestEvent(Request request) { // this.request = request; // } // // @Override // public long getTimestamp() { // return request.getTimestamp(); // } // // public int getUserId() { // return request.getUserId(); // } // // public int getClientIp() { // return request.getClientIp(); // } // // public int getServerIp() { // return request.getServerIp(); // } // // public OperationType getOperationType() { // return request.getOperationType(); // } // // public Protocol getProtocol() { // return request.getProtocol(); // } // // public int getResponseCode() { // return request.getResponseCode(); // } // // public String getUri() { // return request.getUri(); // } // // public int getRequestBytes() { // return request.getRequestBytes(); // } // // public int getResponseBytes() { // return request.getResponseBytes(); // } // // public long getHandshakeUsec() { // return request.getHandshakeUsec(); // } // // public long getUsecToFirstByte() { // return request.getUsecToFirstByte(); // } // // public long getUsecTotal() { // return request.getUsecTotal(); // } // // public String getUserAgent() { // return request.getUserAgent(); // } // // public String getLocale() { // return request.getLocale(); // } // // public String getReferrer() { // return request.getReferrer(); // } // // @Override // public String toString() { // return request.toString(); // } // // }
import com.cscotta.deschutes.api.ConcurrentRollup; import com.cscotta.deschutes.api.RollupFactory; import com.cscotta.deschutes.example.requests.RequestRollup; import com.cscotta.deschutes.example.requests.RequestEvent;
package com.cscotta.deschutes.example.requests; public class RequestRollups { public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() { @Override public ConcurrentRollup<RequestEvent> buildRollup(long timestamp) {
// Path: src/main/java/com/cscotta/deschutes/api/ConcurrentRollup.java // public interface ConcurrentRollup<Input> extends Event { // // /** // * <p>Rollup method called as events are received by a stream for // * aggregation.</p> // * // * <p>Implementations of ConcurrentRollup should accept {@link Event}s, maintain // * the aggregations desired (sums, averages, histograms, and so on), and expose // * them for downstream {@link OutputListener}s to access as output. See the // * {@link ConcurrentRollup} documentation above for a sample implementation.</p> // * // * @param input An event received by a stream to be rolled up. // */ // public abstract void rollup(Input input); // // public long getTimestamp(); // } // // Path: src/main/java/com/cscotta/deschutes/api/RollupFactory.java // public interface RollupFactory<T> { // // public ConcurrentRollup<T> buildRollup(long timestamp); // // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollup.java // public class RequestRollup implements ConcurrentRollup<RequestEvent> { // // private final long timestamp; // // public RequestRollup(long timestamp) { // this.timestamp = timestamp; // } // // private final AtomicLong requestCount = new AtomicLong(0); // private final AtomicLong totalRequestBytes = new AtomicLong(0); // private final AtomicLong totalResponseBytes = new AtomicLong(0); // // private final Histogram requestBytesHisto = new Histogram(new UniformReservoir()); // private final Histogram responseBytesHisto = new Histogram(new UniformReservoir()); // // private final Histogram handshakeUsec = new Histogram(new UniformReservoir()); // private final Histogram usecToFirstByte = new Histogram(new UniformReservoir()); // private final Histogram usecTotal = new Histogram(new UniformReservoir()); // // // public long getRequestCount() { return requestCount.get(); } // public long getTotalRequestBytes() { return totalRequestBytes.get(); } // public long getTotalResponseBytes() { return totalResponseBytes.get(); } // // public Snapshot getRequestBytesHisto() { return requestBytesHisto.getSnapshot(); } // public Snapshot getResponseBytesHisto() { return responseBytesHisto.getSnapshot(); } // // public Snapshot getHandshakeUsecHisto() { return handshakeUsec.getSnapshot(); } // public Snapshot getUsecToFirstByteHisto() { return usecToFirstByte.getSnapshot(); } // public Snapshot getUsecTotalHisto() { return usecTotal.getSnapshot(); } // // @Override // public void rollup(RequestEvent request) { // requestCount.incrementAndGet(); // totalRequestBytes.addAndGet(request.getRequestBytes()); // totalResponseBytes.addAndGet(request.getResponseBytes()); // requestBytesHisto.update(request.getRequestBytes()); // responseBytesHisto.update(request.getResponseBytes()); // handshakeUsec.update(request.getHandshakeUsec()); // usecToFirstByte.update(request.getUsecToFirstByte()); // usecTotal.update(request.getUsecTotal()); // } // // @Override // public long getTimestamp() { // return this.timestamp; // } // } // // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestEvent.java // public class RequestEvent implements Event { // // private final Request request; // // public RequestEvent(Request request) { // this.request = request; // } // // @Override // public long getTimestamp() { // return request.getTimestamp(); // } // // public int getUserId() { // return request.getUserId(); // } // // public int getClientIp() { // return request.getClientIp(); // } // // public int getServerIp() { // return request.getServerIp(); // } // // public OperationType getOperationType() { // return request.getOperationType(); // } // // public Protocol getProtocol() { // return request.getProtocol(); // } // // public int getResponseCode() { // return request.getResponseCode(); // } // // public String getUri() { // return request.getUri(); // } // // public int getRequestBytes() { // return request.getRequestBytes(); // } // // public int getResponseBytes() { // return request.getResponseBytes(); // } // // public long getHandshakeUsec() { // return request.getHandshakeUsec(); // } // // public long getUsecToFirstByte() { // return request.getUsecToFirstByte(); // } // // public long getUsecTotal() { // return request.getUsecTotal(); // } // // public String getUserAgent() { // return request.getUserAgent(); // } // // public String getLocale() { // return request.getLocale(); // } // // public String getReferrer() { // return request.getReferrer(); // } // // @Override // public String toString() { // return request.toString(); // } // // } // Path: src/main/java/com/cscotta/deschutes/example/requests/RequestRollups.java import com.cscotta.deschutes.api.ConcurrentRollup; import com.cscotta.deschutes.api.RollupFactory; import com.cscotta.deschutes.example.requests.RequestRollup; import com.cscotta.deschutes.example.requests.RequestEvent; package com.cscotta.deschutes.example.requests; public class RequestRollups { public static final RollupFactory<RequestEvent> collapser = new RollupFactory<RequestEvent>() { @Override public ConcurrentRollup<RequestEvent> buildRollup(long timestamp) {
return new RequestRollup(timestamp);
cscotta/deschutes
src/main/java/com/cscotta/deschutes/aggregation/Stream.java
// Path: src/main/java/com/cscotta/deschutes/api/Event.java // public interface Event { // // /** // * Retrieve the timestamp of an event, represented as a long in // * milliseconds since epoch. // * // * @return The timestamp of this event, represented as a long in // * milliseconds since epoch. // */ // public long getTimestamp(); // // } // // Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java // public interface StreamAggregator<Input extends Event> { // // public void observe(Input event); // // public StreamAggregator<Input> addListener(OutputListener<Input> listener); // // } // // Path: src/main/java/com/cscotta/deschutes/example/app/App.java // public class App extends Service<Config> { // // public static final MetricRegistry metrics = new MetricRegistry(); // private static final Logger log = LoggerFactory.getLogger(App.class); // private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1); // ConsoleReporter reporter; // // public static void main(String[] args) throws Exception { // new App().run(args); // } // // @Override // public void initialize(Bootstrap<Config> bootstrap) { // bootstrap.setName("app"); // } // // @Override // public void run(Config config, Environment env) throws Exception { // WebsocketApi websocketApi = new WebsocketApi(); // env.addServlet(websocketApi, "/websocket"); // // // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream. // final Iterable<RequestEvent> reader; // if (config.getDataSource().equals("generated")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new ProtobufReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // } else if (config.getDataSource().equals("preloaded")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new CyclingProtobufPreReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize(); // } else { // reader = new SyntheticProtobufs(1000, 1000); // } // // // Report metrics to the console. // reporter = ConsoleReporter.forRegistry(metrics). // convertRatesTo(TimeUnit.SECONDS). // convertDurationsTo(TimeUnit.MILLISECONDS). // build(); // reporter.start(30, TimeUnit.SECONDS); // // // Initialize websocket output // OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users); // // // Prepare our stream // final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads()); // // // Add aggregator(s) to stream - nonblocking or lock-striped for now. // if (config.getAggregatorType().equals("nonblocking")) { // log.info("Launching non-blocking stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // // } else if (config.getAggregatorType().equals("lock_striped")) { // log.info("Launching lock-striped stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // } else { // log.error("Unknown stream type specified."); // } // // stream.launch(); // // // Optionally terminate program after x seconds for benchmarking purposes. // if (config.getRunFor() > 0) { // log.info("Scheduling termination of program in " + config.getRunFor() + " seconds..."); // stpe.schedule(new Runnable() { // @Override // public void run() { // log.info("Terminating program. Final results: "); // reporter.report(); // System.exit(0); // } // }, config.getRunFor(), TimeUnit.SECONDS); // } // } // }
import com.codahale.metrics.Meter; import com.cscotta.deschutes.api.Event; import com.cscotta.deschutes.api.StreamAggregator; import com.cscotta.deschutes.example.app.App; import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue;
package com.cscotta.deschutes.aggregation; public class Stream<Input extends Event> { private final Iterable<Input> source;
// Path: src/main/java/com/cscotta/deschutes/api/Event.java // public interface Event { // // /** // * Retrieve the timestamp of an event, represented as a long in // * milliseconds since epoch. // * // * @return The timestamp of this event, represented as a long in // * milliseconds since epoch. // */ // public long getTimestamp(); // // } // // Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java // public interface StreamAggregator<Input extends Event> { // // public void observe(Input event); // // public StreamAggregator<Input> addListener(OutputListener<Input> listener); // // } // // Path: src/main/java/com/cscotta/deschutes/example/app/App.java // public class App extends Service<Config> { // // public static final MetricRegistry metrics = new MetricRegistry(); // private static final Logger log = LoggerFactory.getLogger(App.class); // private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1); // ConsoleReporter reporter; // // public static void main(String[] args) throws Exception { // new App().run(args); // } // // @Override // public void initialize(Bootstrap<Config> bootstrap) { // bootstrap.setName("app"); // } // // @Override // public void run(Config config, Environment env) throws Exception { // WebsocketApi websocketApi = new WebsocketApi(); // env.addServlet(websocketApi, "/websocket"); // // // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream. // final Iterable<RequestEvent> reader; // if (config.getDataSource().equals("generated")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new ProtobufReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // } else if (config.getDataSource().equals("preloaded")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new CyclingProtobufPreReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize(); // } else { // reader = new SyntheticProtobufs(1000, 1000); // } // // // Report metrics to the console. // reporter = ConsoleReporter.forRegistry(metrics). // convertRatesTo(TimeUnit.SECONDS). // convertDurationsTo(TimeUnit.MILLISECONDS). // build(); // reporter.start(30, TimeUnit.SECONDS); // // // Initialize websocket output // OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users); // // // Prepare our stream // final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads()); // // // Add aggregator(s) to stream - nonblocking or lock-striped for now. // if (config.getAggregatorType().equals("nonblocking")) { // log.info("Launching non-blocking stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // // } else if (config.getAggregatorType().equals("lock_striped")) { // log.info("Launching lock-striped stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // } else { // log.error("Unknown stream type specified."); // } // // stream.launch(); // // // Optionally terminate program after x seconds for benchmarking purposes. // if (config.getRunFor() > 0) { // log.info("Scheduling termination of program in " + config.getRunFor() + " seconds..."); // stpe.schedule(new Runnable() { // @Override // public void run() { // log.info("Terminating program. Final results: "); // reporter.report(); // System.exit(0); // } // }, config.getRunFor(), TimeUnit.SECONDS); // } // } // } // Path: src/main/java/com/cscotta/deschutes/aggregation/Stream.java import com.codahale.metrics.Meter; import com.cscotta.deschutes.api.Event; import com.cscotta.deschutes.api.StreamAggregator; import com.cscotta.deschutes.example.app.App; import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; package com.cscotta.deschutes.aggregation; public class Stream<Input extends Event> { private final Iterable<Input> source;
private final Meter meter = App.metrics.meter("event_rate");
cscotta/deschutes
src/main/java/com/cscotta/deschutes/aggregation/Stream.java
// Path: src/main/java/com/cscotta/deschutes/api/Event.java // public interface Event { // // /** // * Retrieve the timestamp of an event, represented as a long in // * milliseconds since epoch. // * // * @return The timestamp of this event, represented as a long in // * milliseconds since epoch. // */ // public long getTimestamp(); // // } // // Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java // public interface StreamAggregator<Input extends Event> { // // public void observe(Input event); // // public StreamAggregator<Input> addListener(OutputListener<Input> listener); // // } // // Path: src/main/java/com/cscotta/deschutes/example/app/App.java // public class App extends Service<Config> { // // public static final MetricRegistry metrics = new MetricRegistry(); // private static final Logger log = LoggerFactory.getLogger(App.class); // private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1); // ConsoleReporter reporter; // // public static void main(String[] args) throws Exception { // new App().run(args); // } // // @Override // public void initialize(Bootstrap<Config> bootstrap) { // bootstrap.setName("app"); // } // // @Override // public void run(Config config, Environment env) throws Exception { // WebsocketApi websocketApi = new WebsocketApi(); // env.addServlet(websocketApi, "/websocket"); // // // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream. // final Iterable<RequestEvent> reader; // if (config.getDataSource().equals("generated")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new ProtobufReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // } else if (config.getDataSource().equals("preloaded")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new CyclingProtobufPreReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize(); // } else { // reader = new SyntheticProtobufs(1000, 1000); // } // // // Report metrics to the console. // reporter = ConsoleReporter.forRegistry(metrics). // convertRatesTo(TimeUnit.SECONDS). // convertDurationsTo(TimeUnit.MILLISECONDS). // build(); // reporter.start(30, TimeUnit.SECONDS); // // // Initialize websocket output // OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users); // // // Prepare our stream // final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads()); // // // Add aggregator(s) to stream - nonblocking or lock-striped for now. // if (config.getAggregatorType().equals("nonblocking")) { // log.info("Launching non-blocking stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // // } else if (config.getAggregatorType().equals("lock_striped")) { // log.info("Launching lock-striped stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // } else { // log.error("Unknown stream type specified."); // } // // stream.launch(); // // // Optionally terminate program after x seconds for benchmarking purposes. // if (config.getRunFor() > 0) { // log.info("Scheduling termination of program in " + config.getRunFor() + " seconds..."); // stpe.schedule(new Runnable() { // @Override // public void run() { // log.info("Terminating program. Final results: "); // reporter.report(); // System.exit(0); // } // }, config.getRunFor(), TimeUnit.SECONDS); // } // } // }
import com.codahale.metrics.Meter; import com.cscotta.deschutes.api.Event; import com.cscotta.deschutes.api.StreamAggregator; import com.cscotta.deschutes.example.app.App; import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue;
package com.cscotta.deschutes.aggregation; public class Stream<Input extends Event> { private final Iterable<Input> source; private final Meter meter = App.metrics.meter("event_rate"); private final int processorThreads; private static final Logger log = LoggerFactory.getLogger(Stream.class);
// Path: src/main/java/com/cscotta/deschutes/api/Event.java // public interface Event { // // /** // * Retrieve the timestamp of an event, represented as a long in // * milliseconds since epoch. // * // * @return The timestamp of this event, represented as a long in // * milliseconds since epoch. // */ // public long getTimestamp(); // // } // // Path: src/main/java/com/cscotta/deschutes/api/StreamAggregator.java // public interface StreamAggregator<Input extends Event> { // // public void observe(Input event); // // public StreamAggregator<Input> addListener(OutputListener<Input> listener); // // } // // Path: src/main/java/com/cscotta/deschutes/example/app/App.java // public class App extends Service<Config> { // // public static final MetricRegistry metrics = new MetricRegistry(); // private static final Logger log = LoggerFactory.getLogger(App.class); // private static final ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1); // ConsoleReporter reporter; // // public static void main(String[] args) throws Exception { // new App().run(args); // } // // @Override // public void initialize(Bootstrap<Config> bootstrap) { // bootstrap.setName("app"); // } // // @Override // public void run(Config config, Environment env) throws Exception { // WebsocketApi websocketApi = new WebsocketApi(); // env.addServlet(websocketApi, "/websocket"); // // // Select a protobuf reader, a pre-loaded protobuf reader, or a synthetic stream. // final Iterable<RequestEvent> reader; // if (config.getDataSource().equals("generated")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new ProtobufReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // } else if (config.getDataSource().equals("preloaded")) { // BufferedInputStream input = new BufferedInputStream( // new FileInputStream(new File(config.getDataFile())), 1024 * 1024); // reader = new CyclingProtobufPreReader<Request, RequestEvent>( // Request.PARSER, new RequestEventWrapper(), input); // ((CyclingProtobufPreReader<Request, RequestEvent>) reader).initialize(); // } else { // reader = new SyntheticProtobufs(1000, 1000); // } // // // Report metrics to the console. // reporter = ConsoleReporter.forRegistry(metrics). // convertRatesTo(TimeUnit.SECONDS). // convertDurationsTo(TimeUnit.MILLISECONDS). // build(); // reporter.start(30, TimeUnit.SECONDS); // // // Initialize websocket output // OutputListener<RequestEvent> output = new WebsocketRollupListener(websocketApi.users); // // // Prepare our stream // final Stream<RequestEvent> stream = new Stream<RequestEvent>(reader, config.getProcessorThreads()); // // // Add aggregator(s) to stream - nonblocking or lock-striped for now. // if (config.getAggregatorType().equals("nonblocking")) { // log.info("Launching non-blocking stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // // } else if (config.getAggregatorType().equals("lock_striped")) { // log.info("Launching lock-striped stream."); // stream.addQuery( // new OLAPAggregator<RequestEvent>(Dimensions.protocol, RequestRollups.collapser) // .addListener(new WebsocketRollupListener(websocketApi.users))); // } else { // log.error("Unknown stream type specified."); // } // // stream.launch(); // // // Optionally terminate program after x seconds for benchmarking purposes. // if (config.getRunFor() > 0) { // log.info("Scheduling termination of program in " + config.getRunFor() + " seconds..."); // stpe.schedule(new Runnable() { // @Override // public void run() { // log.info("Terminating program. Final results: "); // reporter.report(); // System.exit(0); // } // }, config.getRunFor(), TimeUnit.SECONDS); // } // } // } // Path: src/main/java/com/cscotta/deschutes/aggregation/Stream.java import com.codahale.metrics.Meter; import com.cscotta.deschutes.api.Event; import com.cscotta.deschutes.api.StreamAggregator; import com.cscotta.deschutes.example.app.App; import com.google.common.collect.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; package com.cscotta.deschutes.aggregation; public class Stream<Input extends Event> { private final Iterable<Input> source; private final Meter meter = App.metrics.meter("event_rate"); private final int processorThreads; private static final Logger log = LoggerFactory.getLogger(Stream.class);
private final List<StreamAggregator<Input>> queries = Lists.newCopyOnWriteArrayList();
cscotta/deschutes
src/main/java/com/cscotta/deschutes/input/ProtobufReader.java
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java // public interface EventWrapper<RawInput, WrappedInput> { // // public WrappedInput wrap(RawInput raw); // // }
import com.cscotta.deschutes.api.EventWrapper; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.Parser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.util.Iterator;
package com.cscotta.deschutes.input; public class ProtobufReader<ProtoType, Input> implements Iterable<Input> { final Parser<ProtoType> parser; final InputStream inputStream;
// Path: src/main/java/com/cscotta/deschutes/api/EventWrapper.java // public interface EventWrapper<RawInput, WrappedInput> { // // public WrappedInput wrap(RawInput raw); // // } // Path: src/main/java/com/cscotta/deschutes/input/ProtobufReader.java import com.cscotta.deschutes.api.EventWrapper; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.Parser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.util.Iterator; package com.cscotta.deschutes.input; public class ProtobufReader<ProtoType, Input> implements Iterable<Input> { final Parser<ProtoType> parser; final InputStream inputStream;
final EventWrapper<ProtoType, Input> eventWrapper;
Gdeeer/deerweather
app/src/main/java/com/deerweather/app/model/DeerWeatherDB.java
// Path: app/src/main/java/com/deerweather/app/db/DeerWeatherOpenHelper.java // public class DeerWeatherOpenHelper extends SQLiteOpenHelper { // // public static final String CREATE_PROVINCE = "create table Province (" // + "id integer primary key autoincrement, " // + "province_name text, " // + "province_code text)"; // // public static final String CREATE_CITY = "create table City (" // + "id integer primary key autoincrement, " // + "city_name text, " // + "city_code text, " // + "province_id integer)"; // // public static final String CREATE_COUNTY = "create table County (" // + "id integer primary key autoincrement, " // + "county_name text, " // + "county_code text, " // + "city_id integer)"; // // public static final String CREATE_MY_COUNTY = "create table MyCounty (" // + "id integer primary key autoincrement, " // + "county_name text, " // + "county_code text, " // + "longitude text, " // + "latitude text)"; // // public static final String CREATE_MY_THEME = "create table MyTheme (" // + "id integer primary key autoincrement, " // + "color_0 integer, " // + "color_1 integer, " // + "color_2 integer, " // + "color_3 integer, " // + "color_4 integer, " // + "color_5 integer, " // + "color_6 integer, " // + "color_7 integer, " // + "color_8 integer, " // + "color_9 integer, " // + "picture_url_0 text, " // + "picture_url_1 text, " // + "picture_url_2 text, " // + "picture_url_3 text, " // + "picture_url_4 text, " // + "picture_url_5 text, " // + "picture_url_6 text, " // + "picture_url_7 text, " // + "picture_url_8 text, " // + "picture_url_9 text) "; // // public DeerWeatherOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { // super(context, name, factory, version); // } // // @Override // public void onCreate(SQLiteDatabase db) { // db.execSQL(CREATE_PROVINCE); // db.execSQL(CREATE_COUNTY); // db.execSQL(CREATE_CITY); // db.execSQL(CREATE_MY_COUNTY); // db.execSQL(CREATE_MY_THEME); // } // // @Override // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // if (oldVersion == 1) { // db.execSQL(CREATE_MY_THEME); // } // // onCreate(db); // } // }
import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.deerweather.app.db.DeerWeatherOpenHelper; import java.util.ArrayList; import java.util.List;
package com.deerweather.app.model; public class DeerWeatherDB { public static final String DB_NAME = "deer_weather"; public static final int VERSION = 2; private static DeerWeatherDB deerWeatherDB; private SQLiteDatabase db; private DeerWeatherDB(Context context) {
// Path: app/src/main/java/com/deerweather/app/db/DeerWeatherOpenHelper.java // public class DeerWeatherOpenHelper extends SQLiteOpenHelper { // // public static final String CREATE_PROVINCE = "create table Province (" // + "id integer primary key autoincrement, " // + "province_name text, " // + "province_code text)"; // // public static final String CREATE_CITY = "create table City (" // + "id integer primary key autoincrement, " // + "city_name text, " // + "city_code text, " // + "province_id integer)"; // // public static final String CREATE_COUNTY = "create table County (" // + "id integer primary key autoincrement, " // + "county_name text, " // + "county_code text, " // + "city_id integer)"; // // public static final String CREATE_MY_COUNTY = "create table MyCounty (" // + "id integer primary key autoincrement, " // + "county_name text, " // + "county_code text, " // + "longitude text, " // + "latitude text)"; // // public static final String CREATE_MY_THEME = "create table MyTheme (" // + "id integer primary key autoincrement, " // + "color_0 integer, " // + "color_1 integer, " // + "color_2 integer, " // + "color_3 integer, " // + "color_4 integer, " // + "color_5 integer, " // + "color_6 integer, " // + "color_7 integer, " // + "color_8 integer, " // + "color_9 integer, " // + "picture_url_0 text, " // + "picture_url_1 text, " // + "picture_url_2 text, " // + "picture_url_3 text, " // + "picture_url_4 text, " // + "picture_url_5 text, " // + "picture_url_6 text, " // + "picture_url_7 text, " // + "picture_url_8 text, " // + "picture_url_9 text) "; // // public DeerWeatherOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { // super(context, name, factory, version); // } // // @Override // public void onCreate(SQLiteDatabase db) { // db.execSQL(CREATE_PROVINCE); // db.execSQL(CREATE_COUNTY); // db.execSQL(CREATE_CITY); // db.execSQL(CREATE_MY_COUNTY); // db.execSQL(CREATE_MY_THEME); // } // // @Override // public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // if (oldVersion == 1) { // db.execSQL(CREATE_MY_THEME); // } // // onCreate(db); // } // } // Path: app/src/main/java/com/deerweather/app/model/DeerWeatherDB.java import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import com.deerweather.app.db.DeerWeatherOpenHelper; import java.util.ArrayList; import java.util.List; package com.deerweather.app.model; public class DeerWeatherDB { public static final String DB_NAME = "deer_weather"; public static final int VERSION = 2; private static DeerWeatherDB deerWeatherDB; private SQLiteDatabase db; private DeerWeatherDB(Context context) {
DeerWeatherOpenHelper dbHelper = new DeerWeatherOpenHelper(context, DB_NAME, null, VERSION);
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/CalculatedColumnsTest.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/AbstractJStatMetricProvider.java // public abstract class AbstractJStatMetricProvider implements JStatMetricProvider { // @Override // public String getColumnEnhanced(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // return current.getRawColumnData()[i]; // } // @Override // public boolean metricsAvailableOnFirstJStatRun() { // return true; // } // @Override // public String getEnhancedHeader() { // return null; // } // @Override // public String getDescription() { // return null; // } // @Override // public String getOriginalHeader() { // return null; // } // @Override // public int getIndexOfFirstEnhancedColumn() { // return -1; // } // // @Override // public String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // String oneNumberInOneColumn = this.getColumnEnhanced(skipCalculatedCol, current, previous, measurementIntervalInMilliSeconds, i); // return String.format("%6s", oneNumberInOneColumn); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.metricprovider.AbstractJStatMetricProvider; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider;
package com.github.eostermueller.heapspank.garbagespank; public class CalculatedColumnsTest { private static final String TEST_PREFIX = "T_"; private static final String TEST_LINE = //"COL1 COL2\n" + "235 22153\n"; @Test public void canFormatForPageDataExtractor() {
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/AbstractJStatMetricProvider.java // public abstract class AbstractJStatMetricProvider implements JStatMetricProvider { // @Override // public String getColumnEnhanced(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // return current.getRawColumnData()[i]; // } // @Override // public boolean metricsAvailableOnFirstJStatRun() { // return true; // } // @Override // public String getEnhancedHeader() { // return null; // } // @Override // public String getDescription() { // return null; // } // @Override // public String getOriginalHeader() { // return null; // } // @Override // public int getIndexOfFirstEnhancedColumn() { // return -1; // } // // @Override // public String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // String oneNumberInOneColumn = this.getColumnEnhanced(skipCalculatedCol, current, previous, measurementIntervalInMilliSeconds, i); // return String.format("%6s", oneNumberInOneColumn); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/CalculatedColumnsTest.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.metricprovider.AbstractJStatMetricProvider; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider; package com.github.eostermueller.heapspank.garbagespank; public class CalculatedColumnsTest { private static final String TEST_PREFIX = "T_"; private static final String TEST_LINE = //"COL1 COL2\n" + "235 22153\n"; @Test public void canFormatForPageDataExtractor() {
AbstractJStatMetricProvider metricNames = new AbstractJStatMetricProvider() {
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/leakyspank/TestCustomConfigClass.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/CommandLineParameterException.java // public class CommandLineParameterException extends Exception { // // private String proposedConfigClassName = null; // public CommandLineParameterException(String string) { // super(string); // } // public CommandLineParameterException(String string, Throwable t) { // super(string, t); // } // public String getProposedConfigClassName() { // return this.proposedConfigClassName; // } // public void setProposedConfigClassName(String val) { // this.proposedConfigClassName = val; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java // public interface Config { // public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; // // public abstract int getScreenRefreshIntervalSeconds(); // // public abstract void setScreenRefreshIntervalSeconds( // int screenRefreshIntervalSeconds); // // int getjMapHistoIntervalSeconds(); // // void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); // // void setjMapCountPerWindow(int jMapCountPerWindow); // // int getjMapCountPerWindow(); // // void setSuspectCountPerWindow(int suspectCountPerWindow); // // int getSuspectCountPerWindow(); // // public abstract long getPid(); // // void setViewClass(String viewClass); // // String getViewClass(); // // public abstract int getMaxIterations(); // // void setArgs(String[] args) throws CommandLineParameterException; // // void setRunSelfTestAndExit(boolean runSelfTestOnly); // // boolean runSelfTestAndExit(); // // public void setRegExExclusionFilter(String string); // // public String getRegExExclusionFilter(); // // ClassNameFilter getClassNameExclusionFilter(); // // public int getDisplayRowCount(); // public void setDisplayRowCount(int rows); // public boolean getJMapHistoLive(); // public void setJMapHistoLive(boolean b); // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/ConfigFactory.java // public class ConfigFactory { // private static final String DEFAULT_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.DefaultConfig"; // public static final String APACHE_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.ApacheCommonsConfigFile"; // // private String defaultConfigClass = DEFAULT_CONFIG_IMPL; // /** // * Create a new instance of com.github.eostermueller.heapspank.leakyspank.console.Config // * @param args // * @return // * @throws CommandLineParameterException // */ // public Config createNew(String[] args) throws CommandLineParameterException { // Config rc = null; // String proposedNameOfConfigClass = null; // proposedNameOfConfigClass = getConfigClassName(args); // Object configInstance = null; // // debug("Attempting to load config class [" + proposedNameOfConfigClass + "]"); // try { // Class c = Class.forName(proposedNameOfConfigClass); // configInstance = c.newInstance(); // } catch (Exception e) { // CommandLineParameterException x = new CommandLineParameterException("Unable to create [" + proposedNameOfConfigClass + "]. Not in the classpath?", e); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // if (Config.class.isInstance(configInstance)) { // rc = (Config) configInstance; // rc.setArgs(args); // } else { // CommandLineParameterException x = new CommandLineParameterException("The -config class [" + proposedNameOfConfigClass + "] must implement com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // debug("loaded config [" + rc.toString() + "]"); // return rc; // } // private void debug(String string) { // System.out.println("heapSpank: " + string); // // } // private String getConfigClassName(String[] args) throws CommandLineParameterException { // String rc = null; // for(int i = 0; i < args.length; i++) { // if (args[i].equals("-config")) { // if ( i+1 < args.length) // rc = args[i+1]; // else { // CommandLineParameterException x = new CommandLineParameterException("parameter after -config must be name of a class that implements com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(null); // throw x; // } // } // } // if (rc==null) // rc = this.defaultConfigClass; // return rc; // } // public String getDefaultConfigClass() { // return defaultConfigClass; // } // public void setDefaultConfigClass(String defaultConfigClass) { // this.defaultConfigClass = defaultConfigClass; // } // // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.leakyspank.console.CommandLineParameterException; import com.github.eostermueller.heapspank.leakyspank.console.Config; import com.github.eostermueller.heapspank.leakyspank.console.ConfigFactory;
package com.github.eostermueller.heapspank.leakyspank; public class TestCustomConfigClass { @Test
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/CommandLineParameterException.java // public class CommandLineParameterException extends Exception { // // private String proposedConfigClassName = null; // public CommandLineParameterException(String string) { // super(string); // } // public CommandLineParameterException(String string, Throwable t) { // super(string, t); // } // public String getProposedConfigClassName() { // return this.proposedConfigClassName; // } // public void setProposedConfigClassName(String val) { // this.proposedConfigClassName = val; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java // public interface Config { // public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; // // public abstract int getScreenRefreshIntervalSeconds(); // // public abstract void setScreenRefreshIntervalSeconds( // int screenRefreshIntervalSeconds); // // int getjMapHistoIntervalSeconds(); // // void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); // // void setjMapCountPerWindow(int jMapCountPerWindow); // // int getjMapCountPerWindow(); // // void setSuspectCountPerWindow(int suspectCountPerWindow); // // int getSuspectCountPerWindow(); // // public abstract long getPid(); // // void setViewClass(String viewClass); // // String getViewClass(); // // public abstract int getMaxIterations(); // // void setArgs(String[] args) throws CommandLineParameterException; // // void setRunSelfTestAndExit(boolean runSelfTestOnly); // // boolean runSelfTestAndExit(); // // public void setRegExExclusionFilter(String string); // // public String getRegExExclusionFilter(); // // ClassNameFilter getClassNameExclusionFilter(); // // public int getDisplayRowCount(); // public void setDisplayRowCount(int rows); // public boolean getJMapHistoLive(); // public void setJMapHistoLive(boolean b); // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/ConfigFactory.java // public class ConfigFactory { // private static final String DEFAULT_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.DefaultConfig"; // public static final String APACHE_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.ApacheCommonsConfigFile"; // // private String defaultConfigClass = DEFAULT_CONFIG_IMPL; // /** // * Create a new instance of com.github.eostermueller.heapspank.leakyspank.console.Config // * @param args // * @return // * @throws CommandLineParameterException // */ // public Config createNew(String[] args) throws CommandLineParameterException { // Config rc = null; // String proposedNameOfConfigClass = null; // proposedNameOfConfigClass = getConfigClassName(args); // Object configInstance = null; // // debug("Attempting to load config class [" + proposedNameOfConfigClass + "]"); // try { // Class c = Class.forName(proposedNameOfConfigClass); // configInstance = c.newInstance(); // } catch (Exception e) { // CommandLineParameterException x = new CommandLineParameterException("Unable to create [" + proposedNameOfConfigClass + "]. Not in the classpath?", e); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // if (Config.class.isInstance(configInstance)) { // rc = (Config) configInstance; // rc.setArgs(args); // } else { // CommandLineParameterException x = new CommandLineParameterException("The -config class [" + proposedNameOfConfigClass + "] must implement com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // debug("loaded config [" + rc.toString() + "]"); // return rc; // } // private void debug(String string) { // System.out.println("heapSpank: " + string); // // } // private String getConfigClassName(String[] args) throws CommandLineParameterException { // String rc = null; // for(int i = 0; i < args.length; i++) { // if (args[i].equals("-config")) { // if ( i+1 < args.length) // rc = args[i+1]; // else { // CommandLineParameterException x = new CommandLineParameterException("parameter after -config must be name of a class that implements com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(null); // throw x; // } // } // } // if (rc==null) // rc = this.defaultConfigClass; // return rc; // } // public String getDefaultConfigClass() { // return defaultConfigClass; // } // public void setDefaultConfigClass(String defaultConfigClass) { // this.defaultConfigClass = defaultConfigClass; // } // // } // Path: src/test/java/com/github/eostermueller/heapspank/leakyspank/TestCustomConfigClass.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.leakyspank.console.CommandLineParameterException; import com.github.eostermueller.heapspank.leakyspank.console.Config; import com.github.eostermueller.heapspank.leakyspank.console.ConfigFactory; package com.github.eostermueller.heapspank.leakyspank; public class TestCustomConfigClass { @Test
public void test() throws CommandLineParameterException {
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/leakyspank/TestCustomConfigClass.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/CommandLineParameterException.java // public class CommandLineParameterException extends Exception { // // private String proposedConfigClassName = null; // public CommandLineParameterException(String string) { // super(string); // } // public CommandLineParameterException(String string, Throwable t) { // super(string, t); // } // public String getProposedConfigClassName() { // return this.proposedConfigClassName; // } // public void setProposedConfigClassName(String val) { // this.proposedConfigClassName = val; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java // public interface Config { // public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; // // public abstract int getScreenRefreshIntervalSeconds(); // // public abstract void setScreenRefreshIntervalSeconds( // int screenRefreshIntervalSeconds); // // int getjMapHistoIntervalSeconds(); // // void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); // // void setjMapCountPerWindow(int jMapCountPerWindow); // // int getjMapCountPerWindow(); // // void setSuspectCountPerWindow(int suspectCountPerWindow); // // int getSuspectCountPerWindow(); // // public abstract long getPid(); // // void setViewClass(String viewClass); // // String getViewClass(); // // public abstract int getMaxIterations(); // // void setArgs(String[] args) throws CommandLineParameterException; // // void setRunSelfTestAndExit(boolean runSelfTestOnly); // // boolean runSelfTestAndExit(); // // public void setRegExExclusionFilter(String string); // // public String getRegExExclusionFilter(); // // ClassNameFilter getClassNameExclusionFilter(); // // public int getDisplayRowCount(); // public void setDisplayRowCount(int rows); // public boolean getJMapHistoLive(); // public void setJMapHistoLive(boolean b); // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/ConfigFactory.java // public class ConfigFactory { // private static final String DEFAULT_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.DefaultConfig"; // public static final String APACHE_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.ApacheCommonsConfigFile"; // // private String defaultConfigClass = DEFAULT_CONFIG_IMPL; // /** // * Create a new instance of com.github.eostermueller.heapspank.leakyspank.console.Config // * @param args // * @return // * @throws CommandLineParameterException // */ // public Config createNew(String[] args) throws CommandLineParameterException { // Config rc = null; // String proposedNameOfConfigClass = null; // proposedNameOfConfigClass = getConfigClassName(args); // Object configInstance = null; // // debug("Attempting to load config class [" + proposedNameOfConfigClass + "]"); // try { // Class c = Class.forName(proposedNameOfConfigClass); // configInstance = c.newInstance(); // } catch (Exception e) { // CommandLineParameterException x = new CommandLineParameterException("Unable to create [" + proposedNameOfConfigClass + "]. Not in the classpath?", e); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // if (Config.class.isInstance(configInstance)) { // rc = (Config) configInstance; // rc.setArgs(args); // } else { // CommandLineParameterException x = new CommandLineParameterException("The -config class [" + proposedNameOfConfigClass + "] must implement com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // debug("loaded config [" + rc.toString() + "]"); // return rc; // } // private void debug(String string) { // System.out.println("heapSpank: " + string); // // } // private String getConfigClassName(String[] args) throws CommandLineParameterException { // String rc = null; // for(int i = 0; i < args.length; i++) { // if (args[i].equals("-config")) { // if ( i+1 < args.length) // rc = args[i+1]; // else { // CommandLineParameterException x = new CommandLineParameterException("parameter after -config must be name of a class that implements com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(null); // throw x; // } // } // } // if (rc==null) // rc = this.defaultConfigClass; // return rc; // } // public String getDefaultConfigClass() { // return defaultConfigClass; // } // public void setDefaultConfigClass(String defaultConfigClass) { // this.defaultConfigClass = defaultConfigClass; // } // // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.leakyspank.console.CommandLineParameterException; import com.github.eostermueller.heapspank.leakyspank.console.Config; import com.github.eostermueller.heapspank.leakyspank.console.ConfigFactory;
package com.github.eostermueller.heapspank.leakyspank; public class TestCustomConfigClass { @Test public void test() throws CommandLineParameterException { String args[] = { "-config", "com.github.eostermueller.heapspank.leakyspank.MyTestConfig" };
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/CommandLineParameterException.java // public class CommandLineParameterException extends Exception { // // private String proposedConfigClassName = null; // public CommandLineParameterException(String string) { // super(string); // } // public CommandLineParameterException(String string, Throwable t) { // super(string, t); // } // public String getProposedConfigClassName() { // return this.proposedConfigClassName; // } // public void setProposedConfigClassName(String val) { // this.proposedConfigClassName = val; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java // public interface Config { // public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; // // public abstract int getScreenRefreshIntervalSeconds(); // // public abstract void setScreenRefreshIntervalSeconds( // int screenRefreshIntervalSeconds); // // int getjMapHistoIntervalSeconds(); // // void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); // // void setjMapCountPerWindow(int jMapCountPerWindow); // // int getjMapCountPerWindow(); // // void setSuspectCountPerWindow(int suspectCountPerWindow); // // int getSuspectCountPerWindow(); // // public abstract long getPid(); // // void setViewClass(String viewClass); // // String getViewClass(); // // public abstract int getMaxIterations(); // // void setArgs(String[] args) throws CommandLineParameterException; // // void setRunSelfTestAndExit(boolean runSelfTestOnly); // // boolean runSelfTestAndExit(); // // public void setRegExExclusionFilter(String string); // // public String getRegExExclusionFilter(); // // ClassNameFilter getClassNameExclusionFilter(); // // public int getDisplayRowCount(); // public void setDisplayRowCount(int rows); // public boolean getJMapHistoLive(); // public void setJMapHistoLive(boolean b); // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/ConfigFactory.java // public class ConfigFactory { // private static final String DEFAULT_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.DefaultConfig"; // public static final String APACHE_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.ApacheCommonsConfigFile"; // // private String defaultConfigClass = DEFAULT_CONFIG_IMPL; // /** // * Create a new instance of com.github.eostermueller.heapspank.leakyspank.console.Config // * @param args // * @return // * @throws CommandLineParameterException // */ // public Config createNew(String[] args) throws CommandLineParameterException { // Config rc = null; // String proposedNameOfConfigClass = null; // proposedNameOfConfigClass = getConfigClassName(args); // Object configInstance = null; // // debug("Attempting to load config class [" + proposedNameOfConfigClass + "]"); // try { // Class c = Class.forName(proposedNameOfConfigClass); // configInstance = c.newInstance(); // } catch (Exception e) { // CommandLineParameterException x = new CommandLineParameterException("Unable to create [" + proposedNameOfConfigClass + "]. Not in the classpath?", e); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // if (Config.class.isInstance(configInstance)) { // rc = (Config) configInstance; // rc.setArgs(args); // } else { // CommandLineParameterException x = new CommandLineParameterException("The -config class [" + proposedNameOfConfigClass + "] must implement com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // debug("loaded config [" + rc.toString() + "]"); // return rc; // } // private void debug(String string) { // System.out.println("heapSpank: " + string); // // } // private String getConfigClassName(String[] args) throws CommandLineParameterException { // String rc = null; // for(int i = 0; i < args.length; i++) { // if (args[i].equals("-config")) { // if ( i+1 < args.length) // rc = args[i+1]; // else { // CommandLineParameterException x = new CommandLineParameterException("parameter after -config must be name of a class that implements com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(null); // throw x; // } // } // } // if (rc==null) // rc = this.defaultConfigClass; // return rc; // } // public String getDefaultConfigClass() { // return defaultConfigClass; // } // public void setDefaultConfigClass(String defaultConfigClass) { // this.defaultConfigClass = defaultConfigClass; // } // // } // Path: src/test/java/com/github/eostermueller/heapspank/leakyspank/TestCustomConfigClass.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.leakyspank.console.CommandLineParameterException; import com.github.eostermueller.heapspank.leakyspank.console.Config; import com.github.eostermueller.heapspank.leakyspank.console.ConfigFactory; package com.github.eostermueller.heapspank.leakyspank; public class TestCustomConfigClass { @Test public void test() throws CommandLineParameterException { String args[] = { "-config", "com.github.eostermueller.heapspank.leakyspank.MyTestConfig" };
Config testConfig = new ConfigFactory().createNew(args);
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/leakyspank/TestCustomConfigClass.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/CommandLineParameterException.java // public class CommandLineParameterException extends Exception { // // private String proposedConfigClassName = null; // public CommandLineParameterException(String string) { // super(string); // } // public CommandLineParameterException(String string, Throwable t) { // super(string, t); // } // public String getProposedConfigClassName() { // return this.proposedConfigClassName; // } // public void setProposedConfigClassName(String val) { // this.proposedConfigClassName = val; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java // public interface Config { // public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; // // public abstract int getScreenRefreshIntervalSeconds(); // // public abstract void setScreenRefreshIntervalSeconds( // int screenRefreshIntervalSeconds); // // int getjMapHistoIntervalSeconds(); // // void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); // // void setjMapCountPerWindow(int jMapCountPerWindow); // // int getjMapCountPerWindow(); // // void setSuspectCountPerWindow(int suspectCountPerWindow); // // int getSuspectCountPerWindow(); // // public abstract long getPid(); // // void setViewClass(String viewClass); // // String getViewClass(); // // public abstract int getMaxIterations(); // // void setArgs(String[] args) throws CommandLineParameterException; // // void setRunSelfTestAndExit(boolean runSelfTestOnly); // // boolean runSelfTestAndExit(); // // public void setRegExExclusionFilter(String string); // // public String getRegExExclusionFilter(); // // ClassNameFilter getClassNameExclusionFilter(); // // public int getDisplayRowCount(); // public void setDisplayRowCount(int rows); // public boolean getJMapHistoLive(); // public void setJMapHistoLive(boolean b); // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/ConfigFactory.java // public class ConfigFactory { // private static final String DEFAULT_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.DefaultConfig"; // public static final String APACHE_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.ApacheCommonsConfigFile"; // // private String defaultConfigClass = DEFAULT_CONFIG_IMPL; // /** // * Create a new instance of com.github.eostermueller.heapspank.leakyspank.console.Config // * @param args // * @return // * @throws CommandLineParameterException // */ // public Config createNew(String[] args) throws CommandLineParameterException { // Config rc = null; // String proposedNameOfConfigClass = null; // proposedNameOfConfigClass = getConfigClassName(args); // Object configInstance = null; // // debug("Attempting to load config class [" + proposedNameOfConfigClass + "]"); // try { // Class c = Class.forName(proposedNameOfConfigClass); // configInstance = c.newInstance(); // } catch (Exception e) { // CommandLineParameterException x = new CommandLineParameterException("Unable to create [" + proposedNameOfConfigClass + "]. Not in the classpath?", e); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // if (Config.class.isInstance(configInstance)) { // rc = (Config) configInstance; // rc.setArgs(args); // } else { // CommandLineParameterException x = new CommandLineParameterException("The -config class [" + proposedNameOfConfigClass + "] must implement com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // debug("loaded config [" + rc.toString() + "]"); // return rc; // } // private void debug(String string) { // System.out.println("heapSpank: " + string); // // } // private String getConfigClassName(String[] args) throws CommandLineParameterException { // String rc = null; // for(int i = 0; i < args.length; i++) { // if (args[i].equals("-config")) { // if ( i+1 < args.length) // rc = args[i+1]; // else { // CommandLineParameterException x = new CommandLineParameterException("parameter after -config must be name of a class that implements com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(null); // throw x; // } // } // } // if (rc==null) // rc = this.defaultConfigClass; // return rc; // } // public String getDefaultConfigClass() { // return defaultConfigClass; // } // public void setDefaultConfigClass(String defaultConfigClass) { // this.defaultConfigClass = defaultConfigClass; // } // // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.leakyspank.console.CommandLineParameterException; import com.github.eostermueller.heapspank.leakyspank.console.Config; import com.github.eostermueller.heapspank.leakyspank.console.ConfigFactory;
package com.github.eostermueller.heapspank.leakyspank; public class TestCustomConfigClass { @Test public void test() throws CommandLineParameterException { String args[] = { "-config", "com.github.eostermueller.heapspank.leakyspank.MyTestConfig" };
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/CommandLineParameterException.java // public class CommandLineParameterException extends Exception { // // private String proposedConfigClassName = null; // public CommandLineParameterException(String string) { // super(string); // } // public CommandLineParameterException(String string, Throwable t) { // super(string, t); // } // public String getProposedConfigClassName() { // return this.proposedConfigClassName; // } // public void setProposedConfigClassName(String val) { // this.proposedConfigClassName = val; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java // public interface Config { // public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; // // public abstract int getScreenRefreshIntervalSeconds(); // // public abstract void setScreenRefreshIntervalSeconds( // int screenRefreshIntervalSeconds); // // int getjMapHistoIntervalSeconds(); // // void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); // // void setjMapCountPerWindow(int jMapCountPerWindow); // // int getjMapCountPerWindow(); // // void setSuspectCountPerWindow(int suspectCountPerWindow); // // int getSuspectCountPerWindow(); // // public abstract long getPid(); // // void setViewClass(String viewClass); // // String getViewClass(); // // public abstract int getMaxIterations(); // // void setArgs(String[] args) throws CommandLineParameterException; // // void setRunSelfTestAndExit(boolean runSelfTestOnly); // // boolean runSelfTestAndExit(); // // public void setRegExExclusionFilter(String string); // // public String getRegExExclusionFilter(); // // ClassNameFilter getClassNameExclusionFilter(); // // public int getDisplayRowCount(); // public void setDisplayRowCount(int rows); // public boolean getJMapHistoLive(); // public void setJMapHistoLive(boolean b); // } // // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/ConfigFactory.java // public class ConfigFactory { // private static final String DEFAULT_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.DefaultConfig"; // public static final String APACHE_CONFIG_IMPL = "com.github.eostermueller.heapspank.leakyspank.console.ApacheCommonsConfigFile"; // // private String defaultConfigClass = DEFAULT_CONFIG_IMPL; // /** // * Create a new instance of com.github.eostermueller.heapspank.leakyspank.console.Config // * @param args // * @return // * @throws CommandLineParameterException // */ // public Config createNew(String[] args) throws CommandLineParameterException { // Config rc = null; // String proposedNameOfConfigClass = null; // proposedNameOfConfigClass = getConfigClassName(args); // Object configInstance = null; // // debug("Attempting to load config class [" + proposedNameOfConfigClass + "]"); // try { // Class c = Class.forName(proposedNameOfConfigClass); // configInstance = c.newInstance(); // } catch (Exception e) { // CommandLineParameterException x = new CommandLineParameterException("Unable to create [" + proposedNameOfConfigClass + "]. Not in the classpath?", e); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // if (Config.class.isInstance(configInstance)) { // rc = (Config) configInstance; // rc.setArgs(args); // } else { // CommandLineParameterException x = new CommandLineParameterException("The -config class [" + proposedNameOfConfigClass + "] must implement com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(proposedNameOfConfigClass); // throw x; // } // // debug("loaded config [" + rc.toString() + "]"); // return rc; // } // private void debug(String string) { // System.out.println("heapSpank: " + string); // // } // private String getConfigClassName(String[] args) throws CommandLineParameterException { // String rc = null; // for(int i = 0; i < args.length; i++) { // if (args[i].equals("-config")) { // if ( i+1 < args.length) // rc = args[i+1]; // else { // CommandLineParameterException x = new CommandLineParameterException("parameter after -config must be name of a class that implements com.github.eostermueller.heapspank.leakyspank.console.Config"); // x.setProposedConfigClassName(null); // throw x; // } // } // } // if (rc==null) // rc = this.defaultConfigClass; // return rc; // } // public String getDefaultConfigClass() { // return defaultConfigClass; // } // public void setDefaultConfigClass(String defaultConfigClass) { // this.defaultConfigClass = defaultConfigClass; // } // // } // Path: src/test/java/com/github/eostermueller/heapspank/leakyspank/TestCustomConfigClass.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.leakyspank.console.CommandLineParameterException; import com.github.eostermueller.heapspank.leakyspank.console.Config; import com.github.eostermueller.heapspank.leakyspank.console.ConfigFactory; package com.github.eostermueller.heapspank.leakyspank; public class TestCustomConfigClass { @Test public void test() throws CommandLineParameterException { String args[] = { "-config", "com.github.eostermueller.heapspank.leakyspank.MyTestConfig" };
Config testConfig = new ConfigFactory().createNew(args);
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/ClassNameFilter.java // public interface ClassNameFilter { // boolean accept(String className); // }
import java.util.List; import com.github.eostermueller.heapspank.leakyspank.ClassNameFilter;
package com.github.eostermueller.heapspank.leakyspank.console; public interface Config { public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; public abstract int getScreenRefreshIntervalSeconds(); public abstract void setScreenRefreshIntervalSeconds( int screenRefreshIntervalSeconds); int getjMapHistoIntervalSeconds(); void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); void setjMapCountPerWindow(int jMapCountPerWindow); int getjMapCountPerWindow(); void setSuspectCountPerWindow(int suspectCountPerWindow); int getSuspectCountPerWindow(); public abstract long getPid(); void setViewClass(String viewClass); String getViewClass(); public abstract int getMaxIterations(); void setArgs(String[] args) throws CommandLineParameterException; void setRunSelfTestAndExit(boolean runSelfTestOnly); boolean runSelfTestAndExit(); public void setRegExExclusionFilter(String string); public String getRegExExclusionFilter();
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/ClassNameFilter.java // public interface ClassNameFilter { // boolean accept(String className); // } // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/Config.java import java.util.List; import com.github.eostermueller.heapspank.leakyspank.ClassNameFilter; package com.github.eostermueller.heapspank.leakyspank.console; public interface Config { public static final String DEFAULT_FILE_NAME = "heapSpank.properties"; public abstract int getScreenRefreshIntervalSeconds(); public abstract void setScreenRefreshIntervalSeconds( int screenRefreshIntervalSeconds); int getjMapHistoIntervalSeconds(); void setjMapHistoIntervalSeconds(int jMapHistoIntervalSeconds); void setjMapCountPerWindow(int jMapCountPerWindow); int getjMapCountPerWindow(); void setSuspectCountPerWindow(int suspectCountPerWindow); int getSuspectCountPerWindow(); public abstract long getPid(); void setViewClass(String viewClass); String getViewClass(); public abstract int getMaxIterations(); void setArgs(String[] args) throws CommandLineParameterException; void setRunSelfTestAndExit(boolean runSelfTestOnly); boolean runSelfTestAndExit(); public void setRegExExclusionFilter(String string); public String getRegExExclusionFilter();
ClassNameFilter getClassNameExclusionFilter();
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcOldCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcOldCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcoldcapacity_metric_names = { "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcoldcapacity_metric_names; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcOldCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcOldCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcoldcapacity_metric_names = { "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcoldcapacity_metric_names; } @Override
public JVMVersion[] getSupportedVersions() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcOldCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcOldCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcoldcapacity_metric_names = { "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcoldcapacity_metric_names; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{JVMVersion.v1_8}; } @Override public String getDescription() { return "Displays statistics about the sizes of the old generation."; } @Override public String getOriginalHeader() { return "OGCMN OGCMX OGC OC YGC FGC FGCT GCT"; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcOldCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcOldCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcoldcapacity_metric_names = { "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcoldcapacity_metric_names; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{JVMVersion.v1_8}; } @Override public String getDescription() { return "Displays statistics about the sizes of the old generation."; } @Override public String getOriginalHeader() { return "OGCMN OGCMX OGC OC YGC FGC FGCT GCT"; } @Override
public JStatOption getJStatOption() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/leakyspank/console/DefaultConfig.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/ClassNameFilter.java // public interface ClassNameFilter { // boolean accept(String className); // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import com.github.eostermueller.heapspank.leakyspank.ClassNameFilter;
package com.github.eostermueller.heapspank.leakyspank.console; public class DefaultConfig implements Config { private boolean jmapHistoLive = false; private static final Object PARM_SELF_TEST = "-selfTest"; private static final String HEAP_SPANK = "heapSpank: ";
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/ClassNameFilter.java // public interface ClassNameFilter { // boolean accept(String className); // } // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/console/DefaultConfig.java import java.util.regex.Matcher; import java.util.regex.Pattern; import com.github.eostermueller.heapspank.leakyspank.ClassNameFilter; package com.github.eostermueller.heapspank.leakyspank.console; public class DefaultConfig implements Config { private boolean jmapHistoLive = false; private static final Object PARM_SELF_TEST = "-selfTest"; private static final String HEAP_SPANK = "heapSpank: ";
private ClassNameFilter classNameFilter = null;
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcNewCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcNewCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcnewcapacity_metric_names = { "NGCMN_Minimum-new-generation-capacity-(kB)", "NGCMX_Maximum-new-generation-capacity-(kB)", "NGC_Current-new-generation-capacity-(kB)", "S0CMX_Maximum-survivor-space-0-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1CMX_Maximum-survivor-space-1-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "ECMX_Maximum-eden-space-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; public String[] getJStatMetricNames() { return gcnewcapacity_metric_names; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcNewCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcNewCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcnewcapacity_metric_names = { "NGCMN_Minimum-new-generation-capacity-(kB)", "NGCMX_Maximum-new-generation-capacity-(kB)", "NGC_Current-new-generation-capacity-(kB)", "S0CMX_Maximum-survivor-space-0-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1CMX_Maximum-survivor-space-1-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "ECMX_Maximum-eden-space-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; public String[] getJStatMetricNames() { return gcnewcapacity_metric_names; } @Override
public JVMVersion[] getSupportedVersions() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcNewCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
"S0CMX_Maximum-survivor-space-0-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1CMX_Maximum-survivor-space-1-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "ECMX_Maximum-eden-space-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; public String[] getJStatMetricNames() { return gcnewcapacity_metric_names; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{ JVMVersion.v1_8 }; } @Override public String getDescription() { return "Displays statistics about the sizes of the new generations and its corresponding spaces."; } @Override public String getOriginalHeader() { return "NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC"; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcNewCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; "S0CMX_Maximum-survivor-space-0-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1CMX_Maximum-survivor-space-1-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "ECMX_Maximum-eden-space-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; public String[] getJStatMetricNames() { return gcnewcapacity_metric_names; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{ JVMVersion.v1_8 }; } @Override public String getDescription() { return "Displays statistics about the sizes of the new generations and its corresponding spaces."; } @Override public String getOriginalHeader() { return "NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC"; } @Override
public JStatOption getJStatOption() {
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/console/JStatHeaderTest.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider;
package com.github.eostermueller.heapspank.garbagespank.console; public class JStatHeaderTest { /** * garbageSpank will use to header to detect the "option" passed to jstat, * so we'll know which metrics to add. */ @Test public void test() {
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/console/JStatHeaderTest.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider; package com.github.eostermueller.heapspank.garbagespank.console; public class JStatHeaderTest { /** * garbageSpank will use to header to detect the "option" passed to jstat, * so we'll know which metrics to add. */ @Test public void test() {
GarbageSpank gs = new GarbageSpank();
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/console/JStatHeaderTest.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider;
package com.github.eostermueller.heapspank.garbagespank.console; public class JStatHeaderTest { /** * garbageSpank will use to header to detect the "option" passed to jstat, * so we'll know which metrics to add. */ @Test public void test() { GarbageSpank gs = new GarbageSpank();
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/console/JStatHeaderTest.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider; package com.github.eostermueller.heapspank.garbagespank.console; public class JStatHeaderTest { /** * garbageSpank will use to header to detect the "option" passed to jstat, * so we'll know which metrics to add. */ @Test public void test() { GarbageSpank gs = new GarbageSpank();
JStatMetricProvider mp = gs.getMetricByHeader("S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT");
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/console/JStatHeaderTest.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider;
package com.github.eostermueller.heapspank.garbagespank.console; public class JStatHeaderTest { /** * garbageSpank will use to header to detect the "option" passed to jstat, * so we'll know which metrics to add. */ @Test public void test() { GarbageSpank gs = new GarbageSpank(); JStatMetricProvider mp = gs.getMetricByHeader("S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT"); assertEquals("Cannot identify jstat 'gcnew' option given its header",
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/console/JStatHeaderTest.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider; package com.github.eostermueller.heapspank.garbagespank.console; public class JStatHeaderTest { /** * garbageSpank will use to header to detect the "option" passed to jstat, * so we'll know which metrics to add. */ @Test public void test() { GarbageSpank gs = new GarbageSpank(); JStatMetricProvider mp = gs.getMetricByHeader("S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT"); assertEquals("Cannot identify jstat 'gcnew' option given its header",
JStatOption.gcnew,
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/leakyspank/TestLimitedSizeQueue.java
// Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // }
import com.github.eostermueller.heapspank.util.LimitedSizeQueue; import static org.junit.Assert.*; import java.util.Iterator; import org.junit.Test;
package com.github.eostermueller.heapspank.leakyspank; public class TestLimitedSizeQueue { @Test public void canTheQueueLimitItsSize() {
// Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // } // Path: src/test/java/com/github/eostermueller/heapspank/leakyspank/TestLimitedSizeQueue.java import com.github.eostermueller.heapspank.util.LimitedSizeQueue; import static org.junit.Assert.*; import java.util.Iterator; import org.junit.Test; package com.github.eostermueller.heapspank.leakyspank; public class TestLimitedSizeQueue { @Test public void canTheQueueLimitItsSize() {
LimitedSizeQueue<String> lsq = new LimitedSizeQueue<String>(3);
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/AbstractJStatMetricProvider.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // }
import com.github.eostermueller.heapspank.garbagespank.JStatLine;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public abstract class AbstractJStatMetricProvider implements JStatMetricProvider { @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/AbstractJStatMetricProvider.java import com.github.eostermueller.heapspank.garbagespank.JStatLine; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public abstract class AbstractJStatMetricProvider implements JStatMetricProvider { @Override
public String getColumnEnhanced(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/leakyspank/Model.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // }
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Hashtable; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult;
package com.github.eostermueller.heapspank.leakyspank; /** * Pojo representing parsed output of one execution of JAVA_HOME/bin/jmap -histo <myPid> */ public class Model { /** * There are a lot of extraneous classes in the jmap -histo output that get in the way of quick troubleshooting. * This list allows us to exclude certain java packages from the output. */ // public static String[] DEFAULT_STARTSWITH_EXCLUDE_FILTER = {"[B","[C","[I","[Z","[D","[F","[J","[L","[S","java"}; // public static String[] DEFAULT_STARTSWITH_EXCLUDE_FILTER = {}; private Hashtable<String,JMapHistoLine> htAllClasses = new Hashtable<String,JMapHistoLine>(); //<JMapHistoLine> private List<JMapHistoLine> alAllClasses = new ArrayList<JMapHistoLine>(); //<JMapHistoLine> private ClassNameFilter classNameExclusionFilter; public JMapHistoLine[] getAll() { return this.alAllClasses.toArray( new JMapHistoLine[0]); } public Model() { } public Model(String jMapHistoStdout) { this(jMapHistoStdout,null); }
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // } // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/Model.java import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Hashtable; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult; package com.github.eostermueller.heapspank.leakyspank; /** * Pojo representing parsed output of one execution of JAVA_HOME/bin/jmap -histo <myPid> */ public class Model { /** * There are a lot of extraneous classes in the jmap -histo output that get in the way of quick troubleshooting. * This list allows us to exclude certain java packages from the output. */ // public static String[] DEFAULT_STARTSWITH_EXCLUDE_FILTER = {"[B","[C","[I","[Z","[D","[F","[J","[L","[S","java"}; // public static String[] DEFAULT_STARTSWITH_EXCLUDE_FILTER = {}; private Hashtable<String,JMapHistoLine> htAllClasses = new Hashtable<String,JMapHistoLine>(); //<JMapHistoLine> private List<JMapHistoLine> alAllClasses = new ArrayList<JMapHistoLine>(); //<JMapHistoLine> private ClassNameFilter classNameExclusionFilter; public JMapHistoLine[] getAll() { return this.alAllClasses.toArray( new JMapHistoLine[0]); } public Model() { } public Model(String jMapHistoStdout) { this(jMapHistoStdout,null); }
public void add(LeakResult[] toAdd) {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java // public abstract class BaseEvent { // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java // public interface EventListener { // public void onEvent(BaseEvent e); // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // }
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult; import com.github.eostermueller.heapspank.util.BaseEvent; import com.github.eostermueller.heapspank.util.EventListener; import com.github.eostermueller.heapspank.util.LimitedSizeQueue;
package com.github.eostermueller.heapspank.leakyspank; public class LeakySpankContext { private List<EventListener> windowClosedListener = new ArrayList<EventListener>(); public void addWindowClosedListener(EventListener e) { this.windowClosedListener.add(e); }
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java // public abstract class BaseEvent { // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java // public interface EventListener { // public void onEvent(BaseEvent e); // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // } // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult; import com.github.eostermueller.heapspank.util.BaseEvent; import com.github.eostermueller.heapspank.util.EventListener; import com.github.eostermueller.heapspank.util.LimitedSizeQueue; package com.github.eostermueller.heapspank.leakyspank; public class LeakySpankContext { private List<EventListener> windowClosedListener = new ArrayList<EventListener>(); public void addWindowClosedListener(EventListener e) { this.windowClosedListener.add(e); }
public static class WindowClosedEvent extends BaseEvent {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java // public abstract class BaseEvent { // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java // public interface EventListener { // public void onEvent(BaseEvent e); // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // }
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult; import com.github.eostermueller.heapspank.util.BaseEvent; import com.github.eostermueller.heapspank.util.EventListener; import com.github.eostermueller.heapspank.util.LimitedSizeQueue;
package com.github.eostermueller.heapspank.leakyspank; public class LeakySpankContext { private List<EventListener> windowClosedListener = new ArrayList<EventListener>(); public void addWindowClosedListener(EventListener e) { this.windowClosedListener.add(e); } public static class WindowClosedEvent extends BaseEvent { } private static final String HEAP_SPANK = "heapSpank: "; private int currentRunCount = 0;
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java // public abstract class BaseEvent { // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java // public interface EventListener { // public void onEvent(BaseEvent e); // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // } // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult; import com.github.eostermueller.heapspank.util.BaseEvent; import com.github.eostermueller.heapspank.util.EventListener; import com.github.eostermueller.heapspank.util.LimitedSizeQueue; package com.github.eostermueller.heapspank.leakyspank; public class LeakySpankContext { private List<EventListener> windowClosedListener = new ArrayList<EventListener>(); public void addWindowClosedListener(EventListener e) { this.windowClosedListener.add(e); } public static class WindowClosedEvent extends BaseEvent { } private static final String HEAP_SPANK = "heapSpank: "; private int currentRunCount = 0;
private LimitedSizeQueue<String> debugDisplayQ;
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java // public abstract class BaseEvent { // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java // public interface EventListener { // public void onEvent(BaseEvent e); // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // }
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult; import com.github.eostermueller.heapspank.util.BaseEvent; import com.github.eostermueller.heapspank.util.EventListener; import com.github.eostermueller.heapspank.util.LimitedSizeQueue;
this.pid = pid; this.intervalInSeconds = interval_in_seconds; this.runCountPerWindow = interval_count; this.setTopNSuspects(topNSupsects); this.setCountPresentThreshold(interval_count); this.recentJMapRuns = new LimitedSizeQueue<Model>(this.getRunCountPerWindow()+1);//the extra one will provide N comparisons between each of the N+1 items. this.setRankIncreaseThreshold(1); //if current JMap -histo 'num' is < prev, then increment LeakResult.countRunsWithRankIncrease } public LeakySpankContext clone(int multiplier) { LeakySpankContext lsc = new LeakySpankContext( this.pid, this.intervalInSeconds*multiplier, this.runCountPerWindow, this.getTopNSuspects() ); return lsc; } public void addJMapHistoRun(Model m) { this.recentJMapRuns.add(m); incrementRunCount(); } private void debug(String msg) { System.out.println(msg); if (this.getDebugDisplayQ()!=null) this.getDebugDisplayQ().offer(msg); }
// Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java // public class LeakResult { // private long timestamp; // LeakResult() { // this.timestamp = System.currentTimeMillis(); // } // public JMapHistoLine line = null; // public int countRunsPresent = 0; // public int countRunsWithLeakierRank = 0; // public int countRunsWithBytesIncrease = 0; // public int countRunsWithInstanceCountIncrease = 0; // // /** // * The percentage of 'runs' that the bytes increase from the previous run. // * @return a double between 0 and 1. Multiply the result by to get a portion of 100%. // */ // public double getPercentageOfRunsWithUpwardByteTrend() { // double rc = 0; // // double totalRunCount = LeakySpankContext.this.getCurrentRunCount() -1; // if (this.countRunsWithBytesIncrease == 0 || totalRunCount == 0) // avoid divide by 0 problems. // rc = 0; // else // rc = this.countRunsWithBytesIncrease / totalRunCount; // // return rc; // } // /** // * Higher score means more likely a leak // * @return // */ // int getLeakScore() { // return this.countRunsPresent+this.countRunsWithLeakierRank+this.countRunsWithBytesIncrease+this.countRunsWithInstanceCountIncrease; // } // public String humanReadable() { // StringBuilder sb = new StringBuilder(); // sb.append("Class=" + line.className + "\n"); // sb.append("\ncountRunsPresent=" + this.countRunsPresent + "\n"); // sb.append("countRunsWithRankIncrease=" + this.countRunsWithLeakierRank + "\n"); // sb.append("countRunsWithBytesIncrease=" + this.countRunsWithBytesIncrease + "\n"); // sb.append("countRunsWithInstanceCountIncrease=" + this.countRunsWithInstanceCountIncrease + "\n"); // return sb.toString(); // } // /** // * update values in 'this' with values from the given LeakResult // * @param oneToAdd // */ // public void update(LeakResult oneToAdd) { // /** // * Add given values to tally values. // */ // this.countRunsPresent+= oneToAdd.countRunsPresent; // this.countRunsWithBytesIncrease += oneToAdd.countRunsWithBytesIncrease; // this.countRunsWithInstanceCountIncrease += oneToAdd.countRunsWithInstanceCountIncrease; // this.countRunsWithLeakierRank += oneToAdd.countRunsWithLeakierRank; // // /** // * display current values of these, instead of outdated values. // */ // this.line.bytes = oneToAdd.line.bytes; // this.line.num = oneToAdd.line.num; // this.line.instances = oneToAdd.line.instances; // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/BaseEvent.java // public abstract class BaseEvent { // // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/EventListener.java // public interface EventListener { // public void onEvent(BaseEvent e); // } // // Path: src/main/java/com/github/eostermueller/heapspank/util/LimitedSizeQueue.java // public class LimitedSizeQueue<E> extends ConcurrentLinkedQueue<E> { // private int limit; // // public LimitedSizeQueue(int limit) { // this.limit = limit; // } // // @Override // public boolean add(E o) { // boolean added = super.add(o); // while (added && size() > limit) { // super.remove(); // } // return added; // } // public E peekFirst() { // Iterator i = this.iterator(); // E item = null; // if (i.hasNext()) // item = (E) i.next(); // return item; // } // public E peekLast() { // Iterator i = this.iterator(); // E item = null; // while(i.hasNext()) { // item = (E) i.next(); // } // return item; // } // // } // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/LeakySpankContext.java import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.List; import com.github.eostermueller.heapspank.leakyspank.LeakySpankContext.LeakResult; import com.github.eostermueller.heapspank.util.BaseEvent; import com.github.eostermueller.heapspank.util.EventListener; import com.github.eostermueller.heapspank.util.LimitedSizeQueue; this.pid = pid; this.intervalInSeconds = interval_in_seconds; this.runCountPerWindow = interval_count; this.setTopNSuspects(topNSupsects); this.setCountPresentThreshold(interval_count); this.recentJMapRuns = new LimitedSizeQueue<Model>(this.getRunCountPerWindow()+1);//the extra one will provide N comparisons between each of the N+1 items. this.setRankIncreaseThreshold(1); //if current JMap -histo 'num' is < prev, then increment LeakResult.countRunsWithRankIncrease } public LeakySpankContext clone(int multiplier) { LeakySpankContext lsc = new LeakySpankContext( this.pid, this.intervalInSeconds*multiplier, this.runCountPerWindow, this.getTopNSuspects() ); return lsc; } public void addJMapHistoRun(Model m) { this.recentJMapRuns.add(m); incrementRunCount(); } private void debug(String msg) { System.out.println(msg); if (this.getDebugDisplayQ()!=null) this.getDebugDisplayQ().offer(msg); }
public List<LeakResult> getLeakSuspectsUnOrdered() {
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/BoringJStatLineTest.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/AbstractJStatMetricProvider.java // public abstract class AbstractJStatMetricProvider implements JStatMetricProvider { // @Override // public String getColumnEnhanced(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // return current.getRawColumnData()[i]; // } // @Override // public boolean metricsAvailableOnFirstJStatRun() { // return true; // } // @Override // public String getEnhancedHeader() { // return null; // } // @Override // public String getDescription() { // return null; // } // @Override // public String getOriginalHeader() { // return null; // } // @Override // public int getIndexOfFirstEnhancedColumn() { // return -1; // } // // @Override // public String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // String oneNumberInOneColumn = this.getColumnEnhanced(skipCalculatedCol, current, previous, measurementIntervalInMilliSeconds, i); // return String.format("%6s", oneNumberInOneColumn); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // }
import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.metricprovider.AbstractJStatMetricProvider; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider;
package com.github.eostermueller.heapspank.garbagespank; public class BoringJStatLineTest { private static final String TEST_PREFIX = "T_"; // private static final String TEST_LINE = // "COL1 COL2\n" + // "235 22153\n"; /** * Note that the jstat header _must_ be stripped off. */ private static final String TEST_LINE = "235 22153\n"; @Test public void canFormatForPageDataExtractor() {
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/AbstractJStatMetricProvider.java // public abstract class AbstractJStatMetricProvider implements JStatMetricProvider { // @Override // public String getColumnEnhanced(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // return current.getRawColumnData()[i]; // } // @Override // public boolean metricsAvailableOnFirstJStatRun() { // return true; // } // @Override // public String getEnhancedHeader() { // return null; // } // @Override // public String getDescription() { // return null; // } // @Override // public String getOriginalHeader() { // return null; // } // @Override // public int getIndexOfFirstEnhancedColumn() { // return -1; // } // // @Override // public String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, JStatLine current, JStatLine previous, long measurementIntervalInMilliSeconds, int i) { // String oneNumberInOneColumn = this.getColumnEnhanced(skipCalculatedCol, current, previous, measurementIntervalInMilliSeconds, i); // return String.format("%6s", oneNumberInOneColumn); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/BoringJStatLineTest.java import static org.junit.Assert.*; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.metricprovider.AbstractJStatMetricProvider; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider; package com.github.eostermueller.heapspank.garbagespank; public class BoringJStatLineTest { private static final String TEST_PREFIX = "T_"; // private static final String TEST_LINE = // "COL1 COL2\n" + // "235 22153\n"; /** * Note that the jstat header _must_ be stripped off. */ private static final String TEST_LINE = "235 22153\n"; @Test public void canFormatForPageDataExtractor() {
AbstractJStatMetricProvider metricNames = new AbstractJStatMetricProvider() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // }
import java.util.Arrays; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider;
package com.github.eostermueller.heapspank.garbagespank; /** * Reads in one row of this from $JAVA_HOME/bin/jstat * <PRE> S0 S1 E O M CCS YGC YGCT FGC FGCT GCT 0.00 0.00 63.97 86.27 98.13 96.64 4177 13.151 17 2.668 15.820 </PRE> and parses the individual colums to be reformatted. * @author erikostermueller * */ public class JStatLine { private boolean skipCalculatedColumns; public void setSkipCalculatedColumns(boolean b) { this.skipCalculatedColumns = b; } public boolean getSkipCalculatedColumns() { return this.skipCalculatedColumns; } JStatLine previous = null; public JStatLine getPrevious() { return previous; } public void setPrevious(JStatLine previousLine) { this.previous = previousLine; } public String[] getRawColumnData() { return columnData; } public void setColumnData(String[] columnData) { this.columnData = columnData; } String[] columnData = null; String prefix = null;
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java // public interface JStatMetricProvider { // public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; // // public int getIndexOfFirstEnhancedColumn(); // // JVMVersion[] getSupportedVersions(); // String getDescription(); // String getOriginalHeader(); // String getEnhancedHeader(); // boolean metricsAvailableOnFirstJStatRun(); // JStatOption getJStatOption(); // String[] getJStatMetricNames(); // /** // * What does enhanced mean? // * Indexes for most columns point to data straight from jstat. // * Other columns, however, require some calculations. // * @param skipCalculatedColumns // // * @param current // * @param previous // * @param mesasurementIntervalInSeconds // * @param i // * @return // */ // String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i); // // String getColumnEnhancedAndFormatted(boolean skipCalculatedCol, // JStatLine current, JStatLine previous, // long measurementIntervalInMilliSeconds, int i); // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java import java.util.Arrays; import com.github.eostermueller.heapspank.garbagespank.metricprovider.JStatMetricProvider; package com.github.eostermueller.heapspank.garbagespank; /** * Reads in one row of this from $JAVA_HOME/bin/jstat * <PRE> S0 S1 E O M CCS YGC YGCT FGC FGCT GCT 0.00 0.00 63.97 86.27 98.13 96.64 4177 13.151 17 2.668 15.820 </PRE> and parses the individual colums to be reformatted. * @author erikostermueller * */ public class JStatLine { private boolean skipCalculatedColumns; public void setSkipCalculatedColumns(boolean b) { this.skipCalculatedColumns = b; } public boolean getSkipCalculatedColumns() { return this.skipCalculatedColumns; } JStatLine previous = null; public JStatLine getPrevious() { return previous; } public void setPrevious(JStatLine previousLine) { this.previous = previousLine; } public String[] getRawColumnData() { return columnData; } public void setColumnData(String[] columnData) { this.columnData = columnData; } String[] columnData = null; String prefix = null;
JStatMetricProvider metricProvider = null;
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/leakyspank/tools/VirtualMachineWrapper.java
// Path: src/main/java/com/github/eostermueller/heapspank/util/IOUtil.java // public class IOUtil { // // private IOUtil() {} // // public static String read(InputStream in) throws IOException { // StringBuilder builder = new StringBuilder(); // byte b[] = new byte[256]; // int n; // do { // n = in.read(b); // if (n > 0) { // builder.append(new String(b, 0, n, "UTF-8")); // } // } while (n > 0); // in.close(); // return builder.toString(); // } // /** // * @stolen from http://stackoverflow.com/questions/35842/how-can-a-java-program-get-its-own-process-id // * @return // */ // public static long getMyPid() { // String processName = // java.lang.management.ManagementFactory.getRuntimeMXBean().getName(); // return Long.parseLong(processName.split("@")[0]); // } // // }
import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import com.github.eostermueller.heapspank.util.IOUtil;
//Class<?> c = loader.loadClass("com.sun.tools.attach.VirtualMachine"); c = loader.loadClass(HOT_SPOT_VM_CLASS_NAME); } catch (Exception e1) { JMapHistoException e2 = new JMapHistoException(e1); throw e2; } return c; } /** * The following link shows that -live or -all must be passed to heapHist() with java 1.8 and greater. * http://cr.openjdk.java.net/~chegar/8153181/00/hotspot/src/share/vm/services/attachListener.cpp.rhs.html * @return * @throws IllegalAccessException * @throws IllegalArgumentException * @throws InvocationTargetException * @throws IOException */ public String heapHisto(boolean live) throws JMapHistoException { String parm = null; if (live) parm = "-live"; else parm = "-all"; Object[] arguments = new Object[] { new String[] { parm } } ; //trigger gc b4 cnt Object rc; String histo = null; try { if (this.heapHistoMethod!=null) { rc = this.heapHistoMethod.invoke(this.vm, arguments); final InputStream in = (InputStream)rc;
// Path: src/main/java/com/github/eostermueller/heapspank/util/IOUtil.java // public class IOUtil { // // private IOUtil() {} // // public static String read(InputStream in) throws IOException { // StringBuilder builder = new StringBuilder(); // byte b[] = new byte[256]; // int n; // do { // n = in.read(b); // if (n > 0) { // builder.append(new String(b, 0, n, "UTF-8")); // } // } while (n > 0); // in.close(); // return builder.toString(); // } // /** // * @stolen from http://stackoverflow.com/questions/35842/how-can-a-java-program-get-its-own-process-id // * @return // */ // public static long getMyPid() { // String processName = // java.lang.management.ManagementFactory.getRuntimeMXBean().getName(); // return Long.parseLong(processName.split("@")[0]); // } // // } // Path: src/main/java/com/github/eostermueller/heapspank/leakyspank/tools/VirtualMachineWrapper.java import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import com.github.eostermueller.heapspank.util.IOUtil; //Class<?> c = loader.loadClass("com.sun.tools.attach.VirtualMachine"); c = loader.loadClass(HOT_SPOT_VM_CLASS_NAME); } catch (Exception e1) { JMapHistoException e2 = new JMapHistoException(e1); throw e2; } return c; } /** * The following link shows that -live or -all must be passed to heapHist() with java 1.8 and greater. * http://cr.openjdk.java.net/~chegar/8153181/00/hotspot/src/share/vm/services/attachListener.cpp.rhs.html * @return * @throws IllegalAccessException * @throws IllegalArgumentException * @throws InvocationTargetException * @throws IOException */ public String heapHisto(boolean live) throws JMapHistoException { String parm = null; if (live) parm = "-live"; else parm = "-all"; Object[] arguments = new Object[] { new String[] { parm } } ; //trigger gc b4 cnt Object rc; String histo = null; try { if (this.heapHistoMethod!=null) { rc = this.heapHistoMethod.invoke(this.vm, arguments); final InputStream in = (InputStream)rc;
histo = IOUtil.read(in);
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gccapacity_metric_names = { "NGCMN_Minimum-new-generation-capacity-(kB)", "NGCMX_Maximum-new-generation-capacity-(kB)", "NGC_Current-new-generation-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "CCSC_Compressed-class-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gccapacity_metric_names = { "NGCMN_Minimum-new-generation-capacity-(kB)", "NGCMX_Maximum-new-generation-capacity-(kB)", "NGC_Current-new-generation-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "CCSC_Compressed-class-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; @Override
public JStatOption getJStatOption() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gccapacity_metric_names = { "NGCMN_Minimum-new-generation-capacity-(kB)", "NGCMX_Maximum-new-generation-capacity-(kB)", "NGC_Current-new-generation-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "CCSC_Compressed-class-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; @Override public JStatOption getJStatOption() { return JStatOption.gccapacity; } public String[] getJStatMetricNames() { return gccapacity_metric_names; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gccapacity_metric_names = { "NGCMN_Minimum-new-generation-capacity-(kB)", "NGCMX_Maximum-new-generation-capacity-(kB)", "NGC_Current-new-generation-capacity-(kB)", "S0C_Current-survivor-space-0-capacity-(kB)", "S1C_Current-survivor-space-1-capacity-(kB)", "EC_Current-eden-space-capacity-(kB)", "OGCMN_Minimum-old-generation-capacity-(kB)", "OGCMX_Maximum-old-generation-capacity-(kB)", "OGC_Current-old-generation-capacity-(kB)", "OC_Current-old-space-capacity-(kB)", "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "CCSC_Compressed-class-space-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events" }; @Override public JStatOption getJStatOption() { return JStatOption.gccapacity; } public String[] getJStatMetricNames() { return gccapacity_metric_names; } @Override
public JVMVersion[] getSupportedVersions() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public interface JStatMetricProvider { public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; public int getIndexOfFirstEnhancedColumn();
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public interface JStatMetricProvider { public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; public int getIndexOfFirstEnhancedColumn();
JVMVersion[] getSupportedVersions();
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public interface JStatMetricProvider { public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; public int getIndexOfFirstEnhancedColumn(); JVMVersion[] getSupportedVersions(); String getDescription(); String getOriginalHeader(); String getEnhancedHeader(); boolean metricsAvailableOnFirstJStatRun();
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public interface JStatMetricProvider { public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; public int getIndexOfFirstEnhancedColumn(); JVMVersion[] getSupportedVersions(); String getDescription(); String getOriginalHeader(); String getEnhancedHeader(); boolean metricsAvailableOnFirstJStatRun();
JStatOption getJStatOption();
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public interface JStatMetricProvider { public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; public int getIndexOfFirstEnhancedColumn(); JVMVersion[] getSupportedVersions(); String getDescription(); String getOriginalHeader(); String getEnhancedHeader(); boolean metricsAvailableOnFirstJStatRun(); JStatOption getJStatOption(); String[] getJStatMetricNames(); /** * What does enhanced mean? * Indexes for most columns point to data straight from jstat. * Other columns, however, require some calculations. * @param skipCalculatedColumns * @param current * @param previous * @param mesasurementIntervalInSeconds * @param i * @return */
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/JStatMetricProvider.java import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public interface JStatMetricProvider { public static final String CALC_COLUMN_NOT_SUPPORTED = "<CalculatedColumnNotSupported>"; public int getIndexOfFirstEnhancedColumn(); JVMVersion[] getSupportedVersions(); String getDescription(); String getOriginalHeader(); String getEnhancedHeader(); boolean metricsAvailableOnFirstJStatRun(); JStatOption getJStatOption(); String[] getJStatMetricNames(); /** * What does enhanced mean? * Indexes for most columns point to data straight from jstat. * Other columns, however, require some calculations. * @param skipCalculatedColumns * @param current * @param previous * @param mesasurementIntervalInSeconds * @param i * @return */
String getColumnEnhanced(boolean skipCalculatedColumns, JStatLine current, JStatLine previous, long mesasurementIntervalInMilliSeconds, int i);
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcOld.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
rc = String.valueOf(percentage); } } else { rc = current.getRawColumnData()[columnIndex]; } return rc; } @Override public boolean metricsAvailableOnFirstJStatRun() { return false; } @Override public JVMVersion[] getSupportedVersions() { // TODO Auto-generated method stub return null; } @Override public String getDescription() { return "Displays statistics about the behavior of the old generation and metaspace statistics."; } @Override public String getOriginalHeader() { return "MC MU CCSC CCSU OC OU YGC FGC FGCT GCT"; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcOld.java import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; rc = String.valueOf(percentage); } } else { rc = current.getRawColumnData()[columnIndex]; } return rc; } @Override public boolean metricsAvailableOnFirstJStatRun() { return false; } @Override public JVMVersion[] getSupportedVersions() { // TODO Auto-generated method stub return null; } @Override public String getDescription() { return "Displays statistics about the behavior of the old generation and metaspace statistics."; } @Override public String getOriginalHeader() { return "MC MU CCSC CCSU OC OU YGC FGC FGCT GCT"; } @Override
public JStatOption getJStatOption() {
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/console/TestEnhancedConsoleUtil.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatHeaderException.java // public class JStatHeaderException extends Exception { // // public JStatHeaderException(String string) { // super(string); // } // // }
import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; import java.nio.charset.StandardCharsets; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatHeaderException;
package com.github.eostermueller.heapspank.garbagespank.console; public class TestEnhancedConsoleUtil { static String GCUTIL_ORIG_OUTPUT_HEADER = "S0 S1 E O M CCS YGC YGCT FGC FGCT GCT"; static String GCUTIL_ORIG_OUTPUT_LINE_1 = "0.00 100.00 22.38 40.13 97.83 95.74 7259 218.792 0 1.100 218.792"; static String GCUTIL_ORIG_OUTPUT_LINE_2 = "0.00 100.00 31.67 72.78 97.83 95.74 7307 220.190 0 1.200 220.190"; private static String GCNEW_ORIG_OUTPUT = GCUTIL_ORIG_OUTPUT_HEADER + "\n" + GCUTIL_ORIG_OUTPUT_LINE_1 + "\n" + GCUTIL_ORIG_OUTPUT_LINE_2; @Test
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatHeaderException.java // public class JStatHeaderException extends Exception { // // public JStatHeaderException(String string) { // super(string); // } // // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/console/TestEnhancedConsoleUtil.java import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; import java.nio.charset.StandardCharsets; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatHeaderException; package com.github.eostermueller.heapspank.garbagespank.console; public class TestEnhancedConsoleUtil { static String GCUTIL_ORIG_OUTPUT_HEADER = "S0 S1 E O M CCS YGC YGCT FGC FGCT GCT"; static String GCUTIL_ORIG_OUTPUT_LINE_1 = "0.00 100.00 22.38 40.13 97.83 95.74 7259 218.792 0 1.100 218.792"; static String GCUTIL_ORIG_OUTPUT_LINE_2 = "0.00 100.00 31.67 72.78 97.83 95.74 7307 220.190 0 1.200 220.190"; private static String GCNEW_ORIG_OUTPUT = GCUTIL_ORIG_OUTPUT_HEADER + "\n" + GCUTIL_ORIG_OUTPUT_LINE_1 + "\n" + GCUTIL_ORIG_OUTPUT_LINE_2; @Test
public void test() throws IOException, JStatHeaderException {
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/console/TestEnhancedConsoleOld.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatHeaderException.java // public class JStatHeaderException extends Exception { // // public JStatHeaderException(String string) { // super(string); // } // // }
import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; import java.nio.charset.StandardCharsets; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatHeaderException;
package com.github.eostermueller.heapspank.garbagespank.console; public class TestEnhancedConsoleOld { static String GCOLD_ORIG_OUTPUT_HEADER = " MC MU CCSC CCSU OC OU YGC FGC FGCT GCT"; static String GCOLD_ORIG_OUTPUT_LINE_1 = " 48128.0 47097.0 5888.0 5637.9 161280.0 89161.4 12973 10 1.775 13.415"; static String GCOLD_ORIG_OUTPUT_LINE_2 = "48128.0 47097.0 5888.0 5637.9 161280.0 89185.4 12975 10 2.775 14.415"; private static String GCNEW_ORIG_OUTPUT = GCOLD_ORIG_OUTPUT_HEADER + "\n" + GCOLD_ORIG_OUTPUT_LINE_1 + "\n" + GCOLD_ORIG_OUTPUT_LINE_2; @Test
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatHeaderException.java // public class JStatHeaderException extends Exception { // // public JStatHeaderException(String string) { // super(string); // } // // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/console/TestEnhancedConsoleOld.java import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; import java.nio.charset.StandardCharsets; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatHeaderException; package com.github.eostermueller.heapspank.garbagespank.console; public class TestEnhancedConsoleOld { static String GCOLD_ORIG_OUTPUT_HEADER = " MC MU CCSC CCSU OC OU YGC FGC FGCT GCT"; static String GCOLD_ORIG_OUTPUT_LINE_1 = " 48128.0 47097.0 5888.0 5637.9 161280.0 89161.4 12973 10 1.775 13.415"; static String GCOLD_ORIG_OUTPUT_LINE_2 = "48128.0 47097.0 5888.0 5637.9 161280.0 89185.4 12975 10 2.775 14.415"; private static String GCNEW_ORIG_OUTPUT = GCOLD_ORIG_OUTPUT_HEADER + "\n" + GCOLD_ORIG_OUTPUT_LINE_1 + "\n" + GCOLD_ORIG_OUTPUT_LINE_2; @Test
public void test() throws IOException, JStatHeaderException {
eostermueller/heapSpank
src/test/java/com/github/eostermueller/heapspank/garbagespank/console/TestEnhancedColsoleNew.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatHeaderException.java // public class JStatHeaderException extends Exception { // // public JStatHeaderException(String string) { // super(string); // } // // }
import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; import java.nio.charset.StandardCharsets; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatHeaderException;
package com.github.eostermueller.heapspank.garbagespank.console; public class TestEnhancedColsoleNew { static String GCNEW_ORIG_OUTPUT_HEADER = "S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT"; static String GCNEW_ORIG_OUTPUT_LINE_1 = "12288.0 12288.0 2784.1 0.0 15 15 12288.0 1155072.0 710885.4 6912 13.415"; static String GCNEW_ORIG_OUTPUT_LINE_2 = "11776.0 11776.0 4559.6 0.0 15 15 11776.0 1156096.0 1029187.1 6914 14.415"; private static String GCNEW_ORIG_OUTPUT = GCNEW_ORIG_OUTPUT_HEADER + "\n" + GCNEW_ORIG_OUTPUT_LINE_1 + "\n" + GCNEW_ORIG_OUTPUT_LINE_2; @Test
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/GarbageSpank.java // public class GarbageSpank { // public static final String GARBAGE_SPANK = "gs_"; // private static ConcurrentHashMap<JStatOption,JStatMetricProvider> metricNames // = new ConcurrentHashMap<JStatOption,JStatMetricProvider>(); // private static ConcurrentHashMap<String,JStatMetricProvider> metricHeaders // = new ConcurrentHashMap<String,JStatMetricProvider>(); // // static { // addProvider( new Gc() ); // addProvider( new GcCapacity() ); // addProvider( new GcMetaCapacity() ); // addProvider( new GcNew() ); // addProvider( new GcNewCapacity() ); // addProvider( new GcOld() ); // addProvider( new GcOldCapacity() ); // addProvider( new GcUtil() ); // /* add more providers below to provide support past JDK 1.8 */ // } // // public static ConcurrentHashMap<JStatOption, JStatMetricProvider> getAllMetricNames() { // return metricNames; // } // public JStatMetricProvider getMetric() { // return getAllMetricNames().get(this.getJStatOption()); // } // public static void setMetricNames( // ConcurrentHashMap<JStatOption, JStatMetricProvider> metricNames) { // GarbageSpank.metricNames = metricNames; // } // public long getPid() { // return pid; // } // public void setPid(long pid) { // this.pid = pid; // } // public JStatOption getJStatOption() { // return jstatOption; // } // public void setJStatOption(JStatOption jstatOption) { // this.jstatOption = jstatOption; // } // public long getIntervalInMilliSeconds() { // return intervalInMilliSeconds; // } // public void setIntervalInMilliSeconds(long intervalInMilliSeconds) { // this.intervalInMilliSeconds = intervalInMilliSeconds; // } // private long pid = -1; // private JStatOption jstatOption = null; // private long intervalInMilliSeconds = -1; // // private static void addProvider(JStatMetricProvider jsmp) { // metricNames.put(jsmp.getJStatOption(), jsmp); // metricHeaders.put(jsmp.getOriginalHeader(), jsmp); // // } // public JStatMetricProvider getMetricNamesByOption(JStatOption jstatOption) { // return this.metricNames.get(jstatOption); // } // public JStatMetricProvider getMetricByHeader(String headerFromJStat) { // return this.metricHeaders.get(headerFromJStat); // } // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatHeaderException.java // public class JStatHeaderException extends Exception { // // public JStatHeaderException(String string) { // super(string); // } // // } // Path: src/test/java/com/github/eostermueller/heapspank/garbagespank/console/TestEnhancedColsoleNew.java import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.io.StringReader; import java.nio.charset.StandardCharsets; import org.junit.Test; import com.github.eostermueller.heapspank.garbagespank.GarbageSpank; import com.github.eostermueller.heapspank.garbagespank.JStatHeaderException; package com.github.eostermueller.heapspank.garbagespank.console; public class TestEnhancedColsoleNew { static String GCNEW_ORIG_OUTPUT_HEADER = "S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT"; static String GCNEW_ORIG_OUTPUT_LINE_1 = "12288.0 12288.0 2784.1 0.0 15 15 12288.0 1155072.0 710885.4 6912 13.415"; static String GCNEW_ORIG_OUTPUT_LINE_2 = "11776.0 11776.0 4559.6 0.0 15 15 11776.0 1156096.0 1029187.1 6914 14.415"; private static String GCNEW_ORIG_OUTPUT = GCNEW_ORIG_OUTPUT_HEADER + "\n" + GCNEW_ORIG_OUTPUT_LINE_1 + "\n" + GCNEW_ORIG_OUTPUT_LINE_2; @Test
public void test() throws IOException, JStatHeaderException {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcNew.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
return rc; } @Override public boolean metricsAvailableOnFirstJStatRun() { return false; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{JVMVersion.v1_8}; } @Override public String getDescription() { return "Displays statistics of the behavior of the new generation."; } /** * This is the header that indicates the jstat was launched with the "-gcnew" parameter */ @Override public String getOriginalHeader() { return "S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT"; } @Override public String getEnhancedHeader() { return this.getOriginalHeader()+" POY"; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatLine.java // public class JStatLine { // private boolean skipCalculatedColumns; // public void setSkipCalculatedColumns(boolean b) { // this.skipCalculatedColumns = b; // } // public boolean getSkipCalculatedColumns() { // return this.skipCalculatedColumns; // } // // JStatLine previous = null; // // public JStatLine getPrevious() { // return previous; // } // // public void setPrevious(JStatLine previousLine) { // this.previous = previousLine; // } // // public String[] getRawColumnData() { // return columnData; // } // // public void setColumnData(String[] columnData) { // this.columnData = columnData; // } // // String[] columnData = null; // String prefix = null; // JStatMetricProvider metricProvider = null; // private String jstatStdOut; // private long measurementIntervalInMilliSeconds; // public JStatLine(String prefix, JStatMetricProvider metricNames, // String jstatStdOut, long measurementIntervalInMilliSeconds) { // // this.metricProvider = metricNames; // this.prefix = prefix; // this.jstatStdOut = jstatStdOut; // this.measurementIntervalInMilliSeconds = measurementIntervalInMilliSeconds; // // parseColumns(); // } // // // private void parseColumns() { // String lineWithData = this.jstatStdOut; // for(int x = 0; x < 5; x++) // lineWithData = lineWithData.replace(" ", " "); // // this.columnData = lineWithData.trim().split(" "); // } // // /** // * Let's say the number "15.820" is index 10. // * If you pass a 10 into this method, it will return a long with 15820, having converted to 15.820 seconds into 15,820 milliseconds. // * @param columnIndex // * @return // */ // public long getRawColumnConvertSecondsToMsLong(int columnIndex) { // String strValInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsLong(strValInSeconds); // } // public long getConvertSecondsToMsLong(String strValInSeconds) { // Double dblTimeSeconds = Double.parseDouble(strValInSeconds.trim()); // long timeMs = (long) (dblTimeSeconds.doubleValue() * 1000); // return timeMs; // } // public double getRawColumnConvertSecondsToMsDouble(int columnIndex) { // String valInSeconds = this.getRawColumnData()[columnIndex]; // return getConvertSecondsToMsDouble(valInSeconds); // } // public double getConvertSecondsToMsDouble(String valInSeconds) { // Double dblValInSeconds = Double.parseDouble(valInSeconds.trim()); // double dblValInMs = (dblValInSeconds.doubleValue() * 1000); // return dblValInMs; // } // public String getConvertMsToSeconds(String val) { // return val; // } // /** // * Format jstat data to be graphed by this component: // * https://jmeter-plugins.org/wiki/PageDataExtractor/ // * @return // */ // public String getPageDataExtractorFormat() { // // StringBuilder sb = new StringBuilder(); // for(int i = 0; i < metricProvider.getJStatMetricNames().length; i++) { // sb.append(prefix); // sb.append( metricProvider.getJStatMetricNames()[i] ); // sb.append("="); // sb.append( this.getDataForColumn(i)); // sb.append("<BR>\n"); // } // return sb.toString(); // } // // private String getDataForColumn(int columnIndex) { // return this.metricProvider.getColumnEnhanced( // this.skipCalculatedColumns, // this, // this.previous, // this.measurementIntervalInMilliSeconds, // columnIndex); // } // // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcNew.java import com.github.eostermueller.heapspank.garbagespank.JStatLine; import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; return rc; } @Override public boolean metricsAvailableOnFirstJStatRun() { return false; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{JVMVersion.v1_8}; } @Override public String getDescription() { return "Displays statistics of the behavior of the new generation."; } /** * This is the header that indicates the jstat was launched with the "-gcnew" parameter */ @Override public String getOriginalHeader() { return "S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT"; } @Override public String getEnhancedHeader() { return this.getOriginalHeader()+" POY"; } @Override
public JStatOption getJStatOption() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcMetaCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcMetaCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcmetacapacity = { "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcmetacapacity; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcMetaCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcMetaCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcmetacapacity = { "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcmetacapacity; } @Override
public JVMVersion[] getSupportedVersions() {
eostermueller/heapSpank
src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcMetaCapacity.java
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // }
import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion;
package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcMetaCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcmetacapacity = { "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcmetacapacity; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{JVMVersion.v1_8}; } @Override public String getDescription() { return "Displays statistics about the sizes of the metaspace."; } @Override public String getOriginalHeader() { return "MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT GCT"; } @Override
// Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JStatOption.java // public enum JStatOption { // gc, // gccapacity, // gcnew, // gcnewcapacity, // gcold, // gcoldcapacity, // gcmetacapacity, // gcutil // } // // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/JVMVersion.java // public enum JVMVersion { // v1_8 // } // Path: src/main/java/com/github/eostermueller/heapspank/garbagespank/metricprovider/GcMetaCapacity.java import com.github.eostermueller.heapspank.garbagespank.JStatOption; import com.github.eostermueller.heapspank.garbagespank.JVMVersion; package com.github.eostermueller.heapspank.garbagespank.metricprovider; public class GcMetaCapacity extends AbstractJStatMetricProvider implements JStatMetricProvider { private static final String[] gcmetacapacity = { "MCMN_Minimum-metaspace-capacity-(kB)", "MCMX_Maximum-metaspace-capacity-(kB)", "MC_Metaspace-capacity-(kB)", "CCSMN_Compressed-class-space-minimum-capacity-(kB)", "CCSMX_Compressed-class-space-maximum-capacity-(kB)", "YGC_Number-of-young-generation-GC-events", "FGC_Number-of-full-GC-events", "FGCT_Full-garbage-collection-time", "GCT_Total-garbage-collection-time" }; public String[] getJStatMetricNames() { return gcmetacapacity; } @Override public JVMVersion[] getSupportedVersions() { return new JVMVersion[]{JVMVersion.v1_8}; } @Override public String getDescription() { return "Displays statistics about the sizes of the metaspace."; } @Override public String getOriginalHeader() { return "MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT GCT"; } @Override
public JStatOption getJStatOption() {
GoogleCloudPlatform/appengine-java-vm-runtime
appengine-jetty-managed-runtime/src/test/java/com/google/apphosting/vmruntime/jetty9/JettyRunner.java
// Path: appengine-jetty-managed-runtime/src/test/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeTestBase.java // public static final String JETTY_HOME_PATTERN = ""//TestUtil.getRunfilesDir() // + "com/google/apphosting/vmruntime/jetty9/" + HOME_FOLDER;
import static com.google.apphosting.vmruntime.jetty9.VmRuntimeTestBase.JETTY_HOME_PATTERN; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.servlet.jsp.JspFactory; import org.apache.jasper.runtime.JspFactoryImpl; import org.apache.tomcat.InstanceManager; import org.apache.tomcat.SimpleInstanceManager; import org.eclipse.jetty.apache.jsp.JettyJasperInitializer; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.NCSARequestLog; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.Assert; import com.google.apphosting.vmruntime.VmRuntimeLogHandler;
finally { Log.getLogger(Server.class).info("Started!"); started.countDown(); } try { if (Log.getLogger(Server.class).isDebugEnabled()) server.dumpStdErr(); server.join(); } catch (Exception e) { e.printStackTrace(); } } /** * Sets the system properties expected by jetty.xml. * * @throws IOException */ protected void setSystemProperties(File logs) throws IOException { String log_file_pattern = logs.getAbsolutePath()+"/log.%g"; System.setProperty( "com.google.apphosting.vmruntime.VmRuntimeFileLogHandler.pattern", log_file_pattern); System.setProperty("jetty.appengineport", me.alexpanov.net.FreePortFinder.findFreeLocalPort() + ""); System.setProperty("jetty.appenginehost", "localhost"); System.setProperty("jetty.appengine.forwarded", "true");
// Path: appengine-jetty-managed-runtime/src/test/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeTestBase.java // public static final String JETTY_HOME_PATTERN = ""//TestUtil.getRunfilesDir() // + "com/google/apphosting/vmruntime/jetty9/" + HOME_FOLDER; // Path: appengine-jetty-managed-runtime/src/test/java/com/google/apphosting/vmruntime/jetty9/JettyRunner.java import static com.google.apphosting.vmruntime.jetty9.VmRuntimeTestBase.JETTY_HOME_PATTERN; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.servlet.jsp.JspFactory; import org.apache.jasper.runtime.JspFactoryImpl; import org.apache.tomcat.InstanceManager; import org.apache.tomcat.SimpleInstanceManager; import org.eclipse.jetty.apache.jsp.JettyJasperInitializer; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.NCSARequestLog; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.Assert; import com.google.apphosting.vmruntime.VmRuntimeLogHandler; finally { Log.getLogger(Server.class).info("Started!"); started.countDown(); } try { if (Log.getLogger(Server.class).isDebugEnabled()) server.dumpStdErr(); server.join(); } catch (Exception e) { e.printStackTrace(); } } /** * Sets the system properties expected by jetty.xml. * * @throws IOException */ protected void setSystemProperties(File logs) throws IOException { String log_file_pattern = logs.getAbsolutePath()+"/log.%g"; System.setProperty( "com.google.apphosting.vmruntime.VmRuntimeFileLogHandler.pattern", log_file_pattern); System.setProperty("jetty.appengineport", me.alexpanov.net.FreePortFinder.findFreeLocalPort() + ""); System.setProperty("jetty.appenginehost", "localhost"); System.setProperty("jetty.appengine.forwarded", "true");
System.setProperty("jetty.home", JETTY_HOME_PATTERN);
vibe-project/vibe-java-platform
websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // }
import java.nio.ByteBuffer; import org.atmosphere.vibe.platform.action.Action;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.websocket; /** * Represents a server-side WebSocket. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://tools.ietf.org/html/rfc6455">RFC6455 - The WebSocket * Protocol</a> */ public interface ServerWebSocket { /** * The URI used to connect. */ String uri(); /** * Closes the connection. This method has no side effect if called more than * once. */ void close(); /** * Sends a text frame through the connection. */ ServerWebSocket send(String data); /** * Sends a binary frame through the connection. */ ServerWebSocket send(ByteBuffer byteBuffer); /** * Attaches an action for the text frame. */
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java import java.nio.ByteBuffer; import org.atmosphere.vibe.platform.action.Action; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.websocket; /** * Represents a server-side WebSocket. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://tools.ietf.org/html/rfc6455">RFC6455 - The WebSocket * Protocol</a> */ public interface ServerWebSocket { /** * The URI used to connect. */ String uri(); /** * Closes the connection. This method has no side effect if called more than * once. */ void close(); /** * Sends a text frame through the connection. */ ServerWebSocket send(String data); /** * Sends a binary frame through the connection. */ ServerWebSocket send(ByteBuffer byteBuffer); /** * Attaches an action for the text frame. */
ServerWebSocket ontext(Action<String> action);
vibe-project/vibe-java-platform
action/src/test/java/org/atmosphere/vibe/platform/action/ConcurrentActionsTest.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // }
import org.atmosphere.vibe.platform.action.Actions.Options;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.action; public class ConcurrentActionsTest extends ActionsTest { @Override protected <T> Actions<T> createActions() { return new ConcurrentActions<>(); } @Override
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // Path: action/src/test/java/org/atmosphere/vibe/platform/action/ConcurrentActionsTest.java import org.atmosphere.vibe.platform.action.Actions.Options; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.action; public class ConcurrentActionsTest extends ActionsTest { @Override protected <T> Actions<T> createActions() { return new ConcurrentActions<>(); } @Override
protected <T> Actions<T> createActions(Options options) {
vibe-project/vibe-java-platform
action/src/test/java/org/atmosphere/vibe/platform/action/SimpleActionsTest.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // }
import org.atmosphere.vibe.platform.action.Actions.Options;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.action; public class SimpleActionsTest extends ActionsTest { @Override protected <T> Actions<T> createActions() { return new SimpleActions<>(); } @Override
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // Path: action/src/test/java/org/atmosphere/vibe/platform/action/SimpleActionsTest.java import org.atmosphere.vibe.platform.action.Actions.Options; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.action; public class SimpleActionsTest extends ActionsTest { @Override protected <T> Actions<T> createActions() { return new SimpleActions<>(); } @Override
protected <T> Actions<T> createActions(Options options) {
vibe-project/vibe-java-platform
http/src/main/java/org/atmosphere/vibe/platform/http/ServerHttpExchange.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // }
import java.nio.ByteBuffer; import java.util.List; import java.util.Set; import org.atmosphere.vibe.platform.action.Action;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.http; /** * Represents a server-side HTTP request-response exchange. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC2616 - * Hypertext Transfer Protocol -- HTTP/1.1</a> */ public interface ServerHttpExchange { /** * The request URI. */ String uri(); /** * The name of the request method. */ String method(); /** * The names of the request headers. HTTP header is not case-sensitive but * {@link Set} is case-sensitive. */ Set<String> headerNames(); /** * Returns the first request header associated with the given name. */ String header(String name); /** * Returns the request headers associated with the given name or empty list * if no header is found. */ List<String> headers(String name); /** * Reads the request body. If the request header, {@code content-type}, * starts with {@code text/}, the body is read as text, and if not, as * binary. In case of text body, the charset is also determined by the same * header. If it's not given, {@code ISO-8859-1} is used by default. * <p> * The read data will be passed to event handlers as {@link String} if it's * text and {@link ByteBuffer} if it's binary attached through * {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange read(); /** * Reads the request body as text. The charset is determined by the request * header, {@code content-type}. If it's not given, {@code ISO-8859-1} is * used by default. * <p> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(); /** * Reads the request body as text using the given charset. * <p> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(String charsetName); /** * Reads the request body as binary. * <p> * The read data will be passed to event handlers as {@link ByteBuffer} * attached through {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsBinary(); /** * Attaches an action to be called with a chunk from the request body. The * allowed data type is {@link String} for text body and {@link ByteBuffer} * for binary body. */
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // Path: http/src/main/java/org/atmosphere/vibe/platform/http/ServerHttpExchange.java import java.nio.ByteBuffer; import java.util.List; import java.util.Set; import org.atmosphere.vibe.platform.action.Action; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.http; /** * Represents a server-side HTTP request-response exchange. * <p/> * Implementations are not thread-safe. * * @author Donghwan Kim * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">RFC2616 - * Hypertext Transfer Protocol -- HTTP/1.1</a> */ public interface ServerHttpExchange { /** * The request URI. */ String uri(); /** * The name of the request method. */ String method(); /** * The names of the request headers. HTTP header is not case-sensitive but * {@link Set} is case-sensitive. */ Set<String> headerNames(); /** * Returns the first request header associated with the given name. */ String header(String name); /** * Returns the request headers associated with the given name or empty list * if no header is found. */ List<String> headers(String name); /** * Reads the request body. If the request header, {@code content-type}, * starts with {@code text/}, the body is read as text, and if not, as * binary. In case of text body, the charset is also determined by the same * header. If it's not given, {@code ISO-8859-1} is used by default. * <p> * The read data will be passed to event handlers as {@link String} if it's * text and {@link ByteBuffer} if it's binary attached through * {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange read(); /** * Reads the request body as text. The charset is determined by the request * header, {@code content-type}. If it's not given, {@code ISO-8859-1} is * used by default. * <p> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(); /** * Reads the request body as text using the given charset. * <p> * The read data will be passed to event handlers as {@link String} attached * through {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsText(String charsetName); /** * Reads the request body as binary. * <p> * The read data will be passed to event handlers as {@link ByteBuffer} * attached through {@link ServerHttpExchange#onchunk(Action)}. * <p> * This method should be called after adding * {@link ServerHttpExchange#onchunk(Action)}, * {@link ServerHttpExchange#onbody(Action)}, and * {@link ServerHttpExchange#onend(Action)} and has no side effect if called * more than once. */ ServerHttpExchange readAsBinary(); /** * Attaches an action to be called with a chunk from the request body. The * allowed data type is {@link String} for text body and {@link ByteBuffer} * for binary body. */
ServerHttpExchange onchunk(Action<?> action);
vibe-project/vibe-java-platform
websocket/src/main/java/org/atmosphere/vibe/platform/websocket/AbstractServerWebSocket.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // }
import java.nio.ByteBuffer; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.Actions; import org.atmosphere.vibe.platform.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.websocket; /** * Abstract base class for {@link ServerWebSocket}. * * @author Donghwan Kim */ public abstract class AbstractServerWebSocket implements ServerWebSocket { protected final Actions<String> textActions = new SimpleActions<>(); protected final Actions<ByteBuffer> binaryActions = new SimpleActions<>(); protected final Actions<Throwable> errorActions = new SimpleActions<>(); protected final Actions<Void> closeActions = new SimpleActions<>(new Actions.Options().once(true).memory(true)); private final Logger logger = LoggerFactory.getLogger(AbstractServerWebSocket.class); private State state = State.OPEN; public AbstractServerWebSocket() {
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // public interface Actions<T> { // // /** // * Adds an action. // */ // Actions<T> add(Action<T> action); // // /** // * Disables any operation on the actions. This method is useful when // * multiple events are mutually exclusive. // */ // Actions<T> disable(); // // /** // * Determines if the actions has been disabled. // */ // boolean disabled(); // // /** // * Removes all of the actions. // */ // Actions<T> empty(); // // /** // * Fire all of the actions. // */ // Actions<T> fire(); // // /** // * Fire all of the actions with the given value. // */ // Actions<T> fire(T data); // // /** // * Determines if the actions have been called at least once. // */ // boolean fired(); // // /** // * Determines if the actions contains an action. // */ // boolean has(); // // /** // * Determines whether the actions contains the specified action. // */ // boolean has(Action<T> action); // // /** // * Removes an action. // */ // Actions<T> remove(Action<T> action); // // /** // * Options to create an Actions. With the default options, an Action will // * work like a typical event manager. // * // * @author Donghwan Kim // */ // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/SimpleActions.java // public class SimpleActions<T> extends AbstractActions<T> { // // private boolean disabled; // private boolean fired; // private T cached; // // public SimpleActions() { // super(); // } // // public SimpleActions(Actions.Options o) { // super(o); // } // // @Override // protected List<Action<T>> createList() { // return new ArrayList<>(); // } // // @Override // protected void setCache(T data) { // this.cached = data; // } // // @Override // protected T cached() { // return cached; // } // // @Override // protected boolean setDisabled() { // boolean answer = !disabled; // if (answer) { // disabled = true; // } // return answer; // } // // @Override // public boolean disabled() { // return disabled; // } // // @Override // protected void setFired() { // fired = true; // } // // @Override // public boolean fired() { // return fired; // } // // } // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/AbstractServerWebSocket.java import java.nio.ByteBuffer; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.Actions; import org.atmosphere.vibe.platform.action.SimpleActions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.websocket; /** * Abstract base class for {@link ServerWebSocket}. * * @author Donghwan Kim */ public abstract class AbstractServerWebSocket implements ServerWebSocket { protected final Actions<String> textActions = new SimpleActions<>(); protected final Actions<ByteBuffer> binaryActions = new SimpleActions<>(); protected final Actions<Throwable> errorActions = new SimpleActions<>(); protected final Actions<Void> closeActions = new SimpleActions<>(new Actions.Options().once(true).memory(true)); private final Logger logger = LoggerFactory.getLogger(AbstractServerWebSocket.class); private State state = State.OPEN; public AbstractServerWebSocket() {
errorActions.add(new Action<Throwable>() {
vibe-project/vibe-java-platform
action/src/test/java/org/atmosphere/vibe/platform/action/ActionsTest.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // }
import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.atmosphere.vibe.platform.action.Actions.Options; import org.junit.Test;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.action; public abstract class ActionsTest { @Test public void options() {
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Actions.java // class Options { // // private boolean once; // private boolean memory; // private boolean unique; // // public Options() { // } // // public Options(Options options) { // once = options.once; // memory = options.memory; // unique = options.unique; // } // // public boolean once() { // return once; // } // // /** // * Ensures the actions can only be fired once. The default value is // * false. // */ // public Options once(boolean once) { // this.once = once; // return this; // } // // public boolean memory() { // return memory; // } // // /** // * Keeps track of previous values and will call any action added after // * the actions has been fired right away with the latest "memorized" // * values. The default value is false. // */ // public Options memory(boolean memory) { // this.memory = memory; // return this; // } // // public boolean unique() { // return unique; // } // // /** // * Ensures an action can only be added once. The default value is false. // */ // public Options unique(boolean unique) { // this.unique = unique; // return this; // } // // } // Path: action/src/test/java/org/atmosphere/vibe/platform/action/ActionsTest.java import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.atmosphere.vibe.platform.action.Actions.Options; import org.junit.Test; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.action; public abstract class ActionsTest { @Test public void options() {
Actions.Options options = new Actions.Options().unique(true);
vibe-project/vibe-java-platform
test/src/main/java/org/atmosphere/vibe/platform/test/ServerWebSocketTest.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/VoidAction.java // public abstract class VoidAction implements Action<Void> { // // @Override // public void on(Void _) { // on(); // } // // public abstract void on(); // // } // // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.VoidAction; import org.atmosphere.vibe.platform.websocket.ServerWebSocket; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.test; /** * Template class to test {@link ServerWebSocket}. * * @author Donghwan Kim */ public abstract class ServerWebSocketTest { @Rule public Timeout globalTimeout = Timeout.seconds(10); protected Performer performer; protected int port; @Before public void before() throws Exception { performer = new Performer(); try (ServerSocket serverSocket = new ServerSocket(0)) { port = serverSocket.getLocalPort(); } startServer(); } @After public void after() throws Exception { stopServer(); } /** * Starts the server listening port {@link ServerWebSocketTest#port} * and if WebSocket's path is {@code /test}, create {@link ServerWebSocket} * and pass it to {@code performer.serverAction()}. This method is executed * following {@link Before}. */ protected abstract void startServer() throws Exception; /** * Stops the server started in * {@link ServerWebSocketTest#startServer()}. This method is * executed following {@link After}. * * @throws Exception */ protected abstract void stopServer() throws Exception; @Test public void uri() {
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/VoidAction.java // public abstract class VoidAction implements Action<Void> { // // @Override // public void on(Void _) { // on(); // } // // public abstract void on(); // // } // // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: test/src/main/java/org/atmosphere/vibe/platform/test/ServerWebSocketTest.java import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.VoidAction; import org.atmosphere.vibe.platform.websocket.ServerWebSocket; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.test; /** * Template class to test {@link ServerWebSocket}. * * @author Donghwan Kim */ public abstract class ServerWebSocketTest { @Rule public Timeout globalTimeout = Timeout.seconds(10); protected Performer performer; protected int port; @Before public void before() throws Exception { performer = new Performer(); try (ServerSocket serverSocket = new ServerSocket(0)) { port = serverSocket.getLocalPort(); } startServer(); } @After public void after() throws Exception { stopServer(); } /** * Starts the server listening port {@link ServerWebSocketTest#port} * and if WebSocket's path is {@code /test}, create {@link ServerWebSocket} * and pass it to {@code performer.serverAction()}. This method is executed * following {@link Before}. */ protected abstract void startServer() throws Exception; /** * Stops the server started in * {@link ServerWebSocketTest#startServer()}. This method is * executed following {@link After}. * * @throws Exception */ protected abstract void stopServer() throws Exception; @Test public void uri() {
performer.onserver(new Action<ServerWebSocket>() {
vibe-project/vibe-java-platform
test/src/main/java/org/atmosphere/vibe/platform/test/ServerWebSocketTest.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/VoidAction.java // public abstract class VoidAction implements Action<Void> { // // @Override // public void on(Void _) { // on(); // } // // public abstract void on(); // // } // // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.VoidAction; import org.atmosphere.vibe.platform.websocket.ServerWebSocket; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
/* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.test; /** * Template class to test {@link ServerWebSocket}. * * @author Donghwan Kim */ public abstract class ServerWebSocketTest { @Rule public Timeout globalTimeout = Timeout.seconds(10); protected Performer performer; protected int port; @Before public void before() throws Exception { performer = new Performer(); try (ServerSocket serverSocket = new ServerSocket(0)) { port = serverSocket.getLocalPort(); } startServer(); } @After public void after() throws Exception { stopServer(); } /** * Starts the server listening port {@link ServerWebSocketTest#port} * and if WebSocket's path is {@code /test}, create {@link ServerWebSocket} * and pass it to {@code performer.serverAction()}. This method is executed * following {@link Before}. */ protected abstract void startServer() throws Exception; /** * Stops the server started in * {@link ServerWebSocketTest#startServer()}. This method is * executed following {@link After}. * * @throws Exception */ protected abstract void stopServer() throws Exception; @Test public void uri() {
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/VoidAction.java // public abstract class VoidAction implements Action<Void> { // // @Override // public void on(Void _) { // on(); // } // // public abstract void on(); // // } // // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: test/src/main/java/org/atmosphere/vibe/platform/test/ServerWebSocketTest.java import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.VoidAction; import org.atmosphere.vibe.platform.websocket.ServerWebSocket; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; /* * Copyright 2014 The Vibe Project * * 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. */ package org.atmosphere.vibe.platform.test; /** * Template class to test {@link ServerWebSocket}. * * @author Donghwan Kim */ public abstract class ServerWebSocketTest { @Rule public Timeout globalTimeout = Timeout.seconds(10); protected Performer performer; protected int port; @Before public void before() throws Exception { performer = new Performer(); try (ServerSocket serverSocket = new ServerSocket(0)) { port = serverSocket.getLocalPort(); } startServer(); } @After public void after() throws Exception { stopServer(); } /** * Starts the server listening port {@link ServerWebSocketTest#port} * and if WebSocket's path is {@code /test}, create {@link ServerWebSocket} * and pass it to {@code performer.serverAction()}. This method is executed * following {@link Before}. */ protected abstract void startServer() throws Exception; /** * Stops the server started in * {@link ServerWebSocketTest#startServer()}. This method is * executed following {@link After}. * * @throws Exception */ protected abstract void stopServer() throws Exception; @Test public void uri() {
performer.onserver(new Action<ServerWebSocket>() {
vibe-project/vibe-java-platform
test/src/main/java/org/atmosphere/vibe/platform/test/ServerWebSocketTest.java
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/VoidAction.java // public abstract class VoidAction implements Action<Void> { // // @Override // public void on(Void _) { // on(); // } // // public abstract void on(); // // } // // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // }
import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.VoidAction; import org.atmosphere.vibe.platform.websocket.ServerWebSocket; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout;
public void on(String data) { assertThat(data, is("A road of winds the water builds")); if (done) { performer.start(); } else { done = true; } } }) .onbinary(new Action<ByteBuffer>() { @Override public void on(ByteBuffer data) { assertThat(data, is(ByteBuffer.wrap(new byte[] { 0x00, 0x01, 0x02 }))); if (done) { performer.start(); } else { done = true; } } }); } }) .connect(); } @Test public void onclose_by_server() { performer.onserver(new Action<ServerWebSocket>() { @Override public void on(final ServerWebSocket ws) {
// Path: action/src/main/java/org/atmosphere/vibe/platform/action/Action.java // public interface Action<T> { // // /** // * Some action is taken. // */ // void on(T object); // // } // // Path: action/src/main/java/org/atmosphere/vibe/platform/action/VoidAction.java // public abstract class VoidAction implements Action<Void> { // // @Override // public void on(Void _) { // on(); // } // // public abstract void on(); // // } // // Path: websocket/src/main/java/org/atmosphere/vibe/platform/websocket/ServerWebSocket.java // public interface ServerWebSocket { // // /** // * The URI used to connect. // */ // String uri(); // // /** // * Closes the connection. This method has no side effect if called more than // * once. // */ // void close(); // // /** // * Sends a text frame through the connection. // */ // ServerWebSocket send(String data); // // /** // * Sends a binary frame through the connection. // */ // ServerWebSocket send(ByteBuffer byteBuffer); // // /** // * Attaches an action for the text frame. // */ // ServerWebSocket ontext(Action<String> action); // // /** // * Attaches an action for the binary frame. // */ // ServerWebSocket onbinary(Action<ByteBuffer> action); // // /** // * Attaches an action for the close event. After this event, the instance // * shouldn't be used and all the other events will be disabled. // */ // ServerWebSocket onclose(Action<Void> action); // // /** // * Attaches an action to handle error from various things. Its exact // * behavior is platform-specific and error created by the platform is // * propagated. // */ // ServerWebSocket onerror(Action<Throwable> action); // // /** // * Returns the provider-specific component. // */ // <T> T unwrap(Class<T> clazz); // // } // Path: test/src/main/java/org/atmosphere/vibe/platform/test/ServerWebSocketTest.java import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import java.net.ServerSocket; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import org.atmosphere.vibe.platform.action.Action; import org.atmosphere.vibe.platform.action.VoidAction; import org.atmosphere.vibe.platform.websocket.ServerWebSocket; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketAdapter; import org.eclipse.jetty.websocket.api.WebSocketListener; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; public void on(String data) { assertThat(data, is("A road of winds the water builds")); if (done) { performer.start(); } else { done = true; } } }) .onbinary(new Action<ByteBuffer>() { @Override public void on(ByteBuffer data) { assertThat(data, is(ByteBuffer.wrap(new byte[] { 0x00, 0x01, 0x02 }))); if (done) { performer.start(); } else { done = true; } } }); } }) .connect(); } @Test public void onclose_by_server() { performer.onserver(new Action<ServerWebSocket>() { @Override public void on(final ServerWebSocket ws) {
ws.onclose(new VoidAction() {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // }
import org.scrutmydocs.webapp.api.common.RestAPIException;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.data; public class RestResponseWelcome extends RestResponse<Welcome> { private static final long serialVersionUID = 1L; public RestResponseWelcome(Welcome doc) { super(doc); } public RestResponseWelcome() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java import org.scrutmydocs.webapp.api.common.RestAPIException; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.data; public class RestResponseWelcome extends RestResponse<Welcome> { private static final long serialVersionUID = 1L; public RestResponseWelcome(Welcome doc) { super(doc); } public RestResponseWelcome() { super(); }
public RestResponseWelcome(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/settings/rivers/basic/data/RestResponseRivers.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // }
import org.scrutmydocs.webapp.api.common.data.RestResponse; import java.util.List; import org.scrutmydocs.webapp.api.common.RestAPIException;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.basic.data; public class RestResponseRivers extends RestResponse<List<BasicRiver>> { private static final long serialVersionUID = 1L; public RestResponseRivers(List<BasicRiver> rivers) { super(rivers); } public RestResponseRivers() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // } // Path: src/main/java/org/scrutmydocs/webapp/api/settings/rivers/basic/data/RestResponseRivers.java import org.scrutmydocs.webapp.api.common.data.RestResponse; import java.util.List; import org.scrutmydocs.webapp.api.common.RestAPIException; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.basic.data; public class RestResponseRivers extends RestResponse<List<BasicRiver>> { private static final long serialVersionUID = 1L; public RestResponseRivers(List<BasicRiver> rivers) { super(rivers); } public RestResponseRivers() { super(); }
public RestResponseRivers(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/document/data/RestResponseDocument.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // }
import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.document.data; public class RestResponseDocument extends RestResponse<Document> { private static final long serialVersionUID = 1L; public RestResponseDocument(Document doc) { super(doc); } public RestResponseDocument() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // } // Path: src/main/java/org/scrutmydocs/webapp/api/document/data/RestResponseDocument.java import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.document.data; public class RestResponseDocument extends RestResponse<Document> { private static final long serialVersionUID = 1L; public RestResponseDocument(Document doc) { super(doc); } public RestResponseDocument() { super(); }
public RestResponseDocument(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // }
import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import org.scrutmydocs.webapp.api.common.RestAPIException;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.data; public class RestResponse<T> implements Serializable { private static final long serialVersionUID = 1L; private boolean ok; private String errors[]; private T object; /** * Default constructor : we suppose here that ok = true */ public RestResponse() { this.ok = true; } /** * We can get an object back, so there is no error and ok=true * @param object */ public RestResponse(T object) { this.object = object; this.ok = true; } /** * We build a response when we have errors * @param errors */ public RestResponse(String[] errors) { this.errors = errors; this.ok = false; } /** * We build a response when we have a single exception * @param e */
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import org.scrutmydocs.webapp.api.common.RestAPIException; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.data; public class RestResponse<T> implements Serializable { private static final long serialVersionUID = 1L; private boolean ok; private String errors[]; private T object; /** * Default constructor : we suppose here that ok = true */ public RestResponse() { this.ok = true; } /** * We can get an object back, so there is no error and ok=true * @param object */ public RestResponse(T object) { this.object = object; this.ok = true; } /** * We build a response when we have errors * @param errors */ public RestResponse(String[] errors) { this.errors = errors; this.ok = false; } /** * We build a response when we have a single exception * @param e */
public RestResponse(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/settings/rivers/basic/data/BasicRiver.java
// Path: src/main/java/org/scrutmydocs/webapp/constant/SMDSearchProperties.java // public interface SMDSearchProperties { // // public static final String INDEX_NAME = "docs"; // public static final String INDEX_TYPE_DOC = "doc"; // public static final String INDEX_TYPE_FOLDER = "folder"; // public static final String INDEX_TYPE_FS = "fsRiver"; // // public static final String DOC_FIELD_NAME = "name"; // public static final String DOC_FIELD_DATE = "postDate"; // public static final String DOC_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DOC_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DOC_FIELD_ROOT_PATH = "rootpath"; // // public static final String DIR_FIELD_NAME = "name"; // public static final String DIR_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DIR_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DIR_FIELD_ROOT_PATH = "rootpath"; // // public static final String ES_META_INDEX = "smdadmin"; // public static final String ES_META_RIVERS = "rivers"; // // }
import java.io.Serializable; import org.scrutmydocs.webapp.constant.SMDSearchProperties;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.basic.data; /** * Manage Abstract Rivers metadata * @author PILATO * */ public class BasicRiver implements Serializable { private static final long serialVersionUID = 1L; private String id; private String name; private String indexname; private String typename; private boolean start; // Just to avoid problems with JSon coding/decoding @SuppressWarnings("unused") private String type; /** * @return The river implementation type, for example: fs, rss */ public String getType() { return "dummy"; } /** * Just to avoid problems with JSon coding/decoding * @param type the type to set */ public void setType(String type) { this.type = type; } /** * Default constructor using a dummy name and defaults to * index/type : docs/doc */ public BasicRiver() { this("dummy"); } /** * Default constructor using a dummy name and defaults to * index/type : docs/doc */ public BasicRiver(String id) {
// Path: src/main/java/org/scrutmydocs/webapp/constant/SMDSearchProperties.java // public interface SMDSearchProperties { // // public static final String INDEX_NAME = "docs"; // public static final String INDEX_TYPE_DOC = "doc"; // public static final String INDEX_TYPE_FOLDER = "folder"; // public static final String INDEX_TYPE_FS = "fsRiver"; // // public static final String DOC_FIELD_NAME = "name"; // public static final String DOC_FIELD_DATE = "postDate"; // public static final String DOC_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DOC_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DOC_FIELD_ROOT_PATH = "rootpath"; // // public static final String DIR_FIELD_NAME = "name"; // public static final String DIR_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DIR_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DIR_FIELD_ROOT_PATH = "rootpath"; // // public static final String ES_META_INDEX = "smdadmin"; // public static final String ES_META_RIVERS = "rivers"; // // } // Path: src/main/java/org/scrutmydocs/webapp/api/settings/rivers/basic/data/BasicRiver.java import java.io.Serializable; import org.scrutmydocs.webapp.constant.SMDSearchProperties; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.basic.data; /** * Manage Abstract Rivers metadata * @author PILATO * */ public class BasicRiver implements Serializable { private static final long serialVersionUID = 1L; private String id; private String name; private String indexname; private String typename; private boolean start; // Just to avoid problems with JSon coding/decoding @SuppressWarnings("unused") private String type; /** * @return The river implementation type, for example: fs, rss */ public String getType() { return "dummy"; } /** * Just to avoid problems with JSon coding/decoding * @param type the type to set */ public void setType(String type) { this.type = type; } /** * Default constructor using a dummy name and defaults to * index/type : docs/doc */ public BasicRiver() { this("dummy"); } /** * Default constructor using a dummy name and defaults to * index/type : docs/doc */ public BasicRiver(String id) {
this(id, SMDSearchProperties.INDEX_NAME, SMDSearchProperties.INDEX_TYPE_DOC, "My Dummy River", false);
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/search/data/RestResponseSearchResponse.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // }
import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.search.data; public class RestResponseSearchResponse extends RestResponse<SearchResponse> { private static final long serialVersionUID = 1L; public RestResponseSearchResponse(SearchResponse doc) { super(doc); } public RestResponseSearchResponse() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // } // Path: src/main/java/org/scrutmydocs/webapp/api/search/data/RestResponseSearchResponse.java import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.search.data; public class RestResponseSearchResponse extends RestResponse<SearchResponse> { private static final long serialVersionUID = 1L; public RestResponseSearchResponse(SearchResponse doc) { super(doc); } public RestResponseSearchResponse() { super(); }
public RestResponseSearchResponse(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/settings/rivers/fs/data/RestResponseFSRivers.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // }
import org.scrutmydocs.webapp.api.common.data.RestResponse; import java.util.List; import org.scrutmydocs.webapp.api.common.RestAPIException;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.fs.data; public class RestResponseFSRivers extends RestResponse<List<FSRiver>> { private static final long serialVersionUID = 1L; public RestResponseFSRivers(List<FSRiver> rivers) { super(rivers); } public RestResponseFSRivers() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // } // Path: src/main/java/org/scrutmydocs/webapp/api/settings/rivers/fs/data/RestResponseFSRivers.java import org.scrutmydocs.webapp.api.common.data.RestResponse; import java.util.List; import org.scrutmydocs.webapp.api.common.RestAPIException; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.fs.data; public class RestResponseFSRivers extends RestResponse<List<FSRiver>> { private static final long serialVersionUID = 1L; public RestResponseFSRivers(List<FSRiver> rivers) { super(rivers); } public RestResponseFSRivers() { super(); }
public RestResponseFSRivers(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/common/facade/CommonBaseApi.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Api.java // public class Api implements Serializable { // private static final long serialVersionUID = 1L; // // private String url = null; // private String method = null; // private String description = null; // // public Api() { // } // // /** // * @param url // * @param method // * @param description // */ // public Api(String url, String method, String description) { // super(); // this.url = url; // this.method = method; // this.description = description; // } // // // // /** // * @return the url // */ // public String getUrl() { // return url; // } // /** // * @param url the url to set // */ // public void setUrl(String url) { // this.url = url; // } // /** // * @return the method // */ // public String getMethod() { // return method; // } // /** // * @param method the method to set // */ // public void setMethod(String method) { // this.method = method; // } // /** // * @return the description // */ // public String getDescription() { // return description; // } // /** // * @param description the description to set // */ // public void setDescription(String description) { // this.description = description; // } // // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java // public class RestResponseWelcome extends RestResponse<Welcome> { // private static final long serialVersionUID = 1L; // // public RestResponseWelcome(Welcome doc) { // super(doc); // } // // public RestResponseWelcome() { // super(); // } // // public RestResponseWelcome(RestAPIException e) { // super(e); // } // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Welcome.java // public class Welcome implements Serializable { // private static final long serialVersionUID = 1L; // // private String version = null; // private String message = null; // private Api[] apis = null; // // /** // * Default constructor : // */ // public Welcome() { // version = "0.0.1-SNAPSHOT"; // apis = new Api[4]; // apis[0] = new Api("/", "GET", "This API"); // apis[1] = new Api("_help", "GET", "Should give you help on each APIs."); // apis[2] = new Api("/doc", "PUT/GET/DELETE", "Manage documents."); // apis[3] = new Api("/index", "POST/DELETE", "Manage Indices"); // } // // /** // * @param message Message to display to user // */ // public Welcome(String message) { // this(); // this.message = message; // } // // /** // * @return the version // */ // public String getVersion() { // return version; // } // // /** // * @param version the version to set // */ // public void setVersion(String version) { // this.version = version; // } // // /** // * @return the message // */ // public String getMessage() { // return message; // } // // /** // * @param message the message to set // */ // public void setMessage(String message) { // this.message = message; // } // // /** // * @return the apis // */ // public Api[] getApis() { // return apis; // } // // /** // * @param apis the apis to set // */ // public void setApis(Api[] apis) { // this.apis = apis; // } // // // // }
import org.scrutmydocs.webapp.api.common.data.Api; import org.scrutmydocs.webapp.api.common.data.RestResponseWelcome; import org.scrutmydocs.webapp.api.common.data.Welcome; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.facade; public abstract class CommonBaseApi { public abstract String helpMessage();
// Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Api.java // public class Api implements Serializable { // private static final long serialVersionUID = 1L; // // private String url = null; // private String method = null; // private String description = null; // // public Api() { // } // // /** // * @param url // * @param method // * @param description // */ // public Api(String url, String method, String description) { // super(); // this.url = url; // this.method = method; // this.description = description; // } // // // // /** // * @return the url // */ // public String getUrl() { // return url; // } // /** // * @param url the url to set // */ // public void setUrl(String url) { // this.url = url; // } // /** // * @return the method // */ // public String getMethod() { // return method; // } // /** // * @param method the method to set // */ // public void setMethod(String method) { // this.method = method; // } // /** // * @return the description // */ // public String getDescription() { // return description; // } // /** // * @param description the description to set // */ // public void setDescription(String description) { // this.description = description; // } // // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java // public class RestResponseWelcome extends RestResponse<Welcome> { // private static final long serialVersionUID = 1L; // // public RestResponseWelcome(Welcome doc) { // super(doc); // } // // public RestResponseWelcome() { // super(); // } // // public RestResponseWelcome(RestAPIException e) { // super(e); // } // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Welcome.java // public class Welcome implements Serializable { // private static final long serialVersionUID = 1L; // // private String version = null; // private String message = null; // private Api[] apis = null; // // /** // * Default constructor : // */ // public Welcome() { // version = "0.0.1-SNAPSHOT"; // apis = new Api[4]; // apis[0] = new Api("/", "GET", "This API"); // apis[1] = new Api("_help", "GET", "Should give you help on each APIs."); // apis[2] = new Api("/doc", "PUT/GET/DELETE", "Manage documents."); // apis[3] = new Api("/index", "POST/DELETE", "Manage Indices"); // } // // /** // * @param message Message to display to user // */ // public Welcome(String message) { // this(); // this.message = message; // } // // /** // * @return the version // */ // public String getVersion() { // return version; // } // // /** // * @param version the version to set // */ // public void setVersion(String version) { // this.version = version; // } // // /** // * @return the message // */ // public String getMessage() { // return message; // } // // /** // * @param message the message to set // */ // public void setMessage(String message) { // this.message = message; // } // // /** // * @return the apis // */ // public Api[] getApis() { // return apis; // } // // /** // * @param apis the apis to set // */ // public void setApis(Api[] apis) { // this.apis = apis; // } // // // // } // Path: src/main/java/org/scrutmydocs/webapp/api/common/facade/CommonBaseApi.java import org.scrutmydocs.webapp.api.common.data.Api; import org.scrutmydocs.webapp.api.common.data.RestResponseWelcome; import org.scrutmydocs.webapp.api.common.data.Welcome; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.facade; public abstract class CommonBaseApi { public abstract String helpMessage();
public abstract Api[] helpApiList();
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/common/facade/CommonBaseApi.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Api.java // public class Api implements Serializable { // private static final long serialVersionUID = 1L; // // private String url = null; // private String method = null; // private String description = null; // // public Api() { // } // // /** // * @param url // * @param method // * @param description // */ // public Api(String url, String method, String description) { // super(); // this.url = url; // this.method = method; // this.description = description; // } // // // // /** // * @return the url // */ // public String getUrl() { // return url; // } // /** // * @param url the url to set // */ // public void setUrl(String url) { // this.url = url; // } // /** // * @return the method // */ // public String getMethod() { // return method; // } // /** // * @param method the method to set // */ // public void setMethod(String method) { // this.method = method; // } // /** // * @return the description // */ // public String getDescription() { // return description; // } // /** // * @param description the description to set // */ // public void setDescription(String description) { // this.description = description; // } // // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java // public class RestResponseWelcome extends RestResponse<Welcome> { // private static final long serialVersionUID = 1L; // // public RestResponseWelcome(Welcome doc) { // super(doc); // } // // public RestResponseWelcome() { // super(); // } // // public RestResponseWelcome(RestAPIException e) { // super(e); // } // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Welcome.java // public class Welcome implements Serializable { // private static final long serialVersionUID = 1L; // // private String version = null; // private String message = null; // private Api[] apis = null; // // /** // * Default constructor : // */ // public Welcome() { // version = "0.0.1-SNAPSHOT"; // apis = new Api[4]; // apis[0] = new Api("/", "GET", "This API"); // apis[1] = new Api("_help", "GET", "Should give you help on each APIs."); // apis[2] = new Api("/doc", "PUT/GET/DELETE", "Manage documents."); // apis[3] = new Api("/index", "POST/DELETE", "Manage Indices"); // } // // /** // * @param message Message to display to user // */ // public Welcome(String message) { // this(); // this.message = message; // } // // /** // * @return the version // */ // public String getVersion() { // return version; // } // // /** // * @param version the version to set // */ // public void setVersion(String version) { // this.version = version; // } // // /** // * @return the message // */ // public String getMessage() { // return message; // } // // /** // * @param message the message to set // */ // public void setMessage(String message) { // this.message = message; // } // // /** // * @return the apis // */ // public Api[] getApis() { // return apis; // } // // /** // * @param apis the apis to set // */ // public void setApis(Api[] apis) { // this.apis = apis; // } // // // // }
import org.scrutmydocs.webapp.api.common.data.Api; import org.scrutmydocs.webapp.api.common.data.RestResponseWelcome; import org.scrutmydocs.webapp.api.common.data.Welcome; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.facade; public abstract class CommonBaseApi { public abstract String helpMessage(); public abstract Api[] helpApiList(); @RequestMapping(method = RequestMethod.GET, value = "_help") public @ResponseBody
// Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Api.java // public class Api implements Serializable { // private static final long serialVersionUID = 1L; // // private String url = null; // private String method = null; // private String description = null; // // public Api() { // } // // /** // * @param url // * @param method // * @param description // */ // public Api(String url, String method, String description) { // super(); // this.url = url; // this.method = method; // this.description = description; // } // // // // /** // * @return the url // */ // public String getUrl() { // return url; // } // /** // * @param url the url to set // */ // public void setUrl(String url) { // this.url = url; // } // /** // * @return the method // */ // public String getMethod() { // return method; // } // /** // * @param method the method to set // */ // public void setMethod(String method) { // this.method = method; // } // /** // * @return the description // */ // public String getDescription() { // return description; // } // /** // * @param description the description to set // */ // public void setDescription(String description) { // this.description = description; // } // // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java // public class RestResponseWelcome extends RestResponse<Welcome> { // private static final long serialVersionUID = 1L; // // public RestResponseWelcome(Welcome doc) { // super(doc); // } // // public RestResponseWelcome() { // super(); // } // // public RestResponseWelcome(RestAPIException e) { // super(e); // } // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Welcome.java // public class Welcome implements Serializable { // private static final long serialVersionUID = 1L; // // private String version = null; // private String message = null; // private Api[] apis = null; // // /** // * Default constructor : // */ // public Welcome() { // version = "0.0.1-SNAPSHOT"; // apis = new Api[4]; // apis[0] = new Api("/", "GET", "This API"); // apis[1] = new Api("_help", "GET", "Should give you help on each APIs."); // apis[2] = new Api("/doc", "PUT/GET/DELETE", "Manage documents."); // apis[3] = new Api("/index", "POST/DELETE", "Manage Indices"); // } // // /** // * @param message Message to display to user // */ // public Welcome(String message) { // this(); // this.message = message; // } // // /** // * @return the version // */ // public String getVersion() { // return version; // } // // /** // * @param version the version to set // */ // public void setVersion(String version) { // this.version = version; // } // // /** // * @return the message // */ // public String getMessage() { // return message; // } // // /** // * @param message the message to set // */ // public void setMessage(String message) { // this.message = message; // } // // /** // * @return the apis // */ // public Api[] getApis() { // return apis; // } // // /** // * @param apis the apis to set // */ // public void setApis(Api[] apis) { // this.apis = apis; // } // // // // } // Path: src/main/java/org/scrutmydocs/webapp/api/common/facade/CommonBaseApi.java import org.scrutmydocs.webapp.api.common.data.Api; import org.scrutmydocs.webapp.api.common.data.RestResponseWelcome; import org.scrutmydocs.webapp.api.common.data.Welcome; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.facade; public abstract class CommonBaseApi { public abstract String helpMessage(); public abstract Api[] helpApiList(); @RequestMapping(method = RequestMethod.GET, value = "_help") public @ResponseBody
RestResponseWelcome welcomeHelp() {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/configuration/AppConfig.java
// Path: src/main/java/org/scrutmydocs/webapp/util/PropertyScanner.java // public class PropertyScanner { // // public static ScrutMyDocsProperties scanPropertyFile() throws IOException { // ScrutMyDocsProperties smdProps = new ScrutMyDocsProperties(); // // String userHome = System.getProperty("user.home"); // FileSystemResource resource = new FileSystemResource(userHome + "/.scrutmydocs/config/scrutmydocs.properties"); // Properties props = null; // try { // props = PropertiesLoaderUtils.loadProperties(resource); // } catch (FileNotFoundException e) { // // File does not exists ? Who cares ? // } // // if (props == null) { // // Build the file from the Classpath // FileSystemResource configDir = new FileSystemResource(userHome + "/.scrutmydocs/config/"); // ClassPathResource classPathResource = new ClassPathResource("/scrutmydocs/config/scrutmydocs.properties"); // // File from = classPathResource.getFile(); // File dest = new File(configDir.getFile(),from.getName()); // Files.createParentDirs(dest); // Files.copy(from, dest); // // props = PropertiesLoaderUtils.loadProperties(resource); // } // // if (props == null) { // throw new RuntimeException("Can not build ~/.scrutmydocs/config/scrutmydocs.properties file. Check that current user have a write access"); // } // else { // smdProps.setNodeEmbedded(getProperty(props, "node.embedded", true)); // smdProps.setClusterName(getProperty(props, "cluster.name", "scrutmydocs")); // FileSystemResource configDir = new FileSystemResource(userHome + "/.scrutmydocs/config/esdata/"); // smdProps.setPathData(getProperty(props, "path.data", configDir.getPath())); // smdProps.setNodeAdresses(getPropertyAsArray(props, "node.addresses", "localhost:9300,localhost:9301")); // // // We check some rules here : // // if node.embedded = false, we must have an array of node.adresses // if (!smdProps.isNodeEmbedded() && (smdProps.getNodeAdresses() == null || smdProps.getNodeAdresses().length < 1)) { // throw new RuntimeException("If you don't want embedded node, you MUST set node.addresses property."); // } // } // // return smdProps; // } // // private static boolean getProperty(Properties props, String path, // boolean defaultValue) { // String sValue = getProperty(props, path, Boolean.toString(defaultValue)); // if (sValue == null) // return false; // return Boolean.parseBoolean(sValue); // } // // private static String getProperty(Properties props, String path, // String defaultValue) { // return props.getProperty(path, defaultValue); // } // // private static String[] getPropertyAsArray(Properties props, String path, // String defaultValue) { // String sValue = getProperty(props, path, defaultValue); // if (sValue == null) // return null; // // // Remove spaces and split results with comma // String[] arrStr = StringUtils.commaDelimitedListToStringArray(sValue); // // return arrStr; // } // }
import fr.pilato.spring.elasticsearch.ElasticsearchAbstractClientFactoryBean; import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean; import fr.pilato.spring.elasticsearch.ElasticsearchNodeFactoryBean; import fr.pilato.spring.elasticsearch.ElasticsearchTransportClientFactoryBean; import org.elasticsearch.client.Client; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.node.Node; import org.scrutmydocs.webapp.util.PropertyScanner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.configuration; @Configuration public class AppConfig { private ESLogger logger = Loggers.getLogger(getClass().getName()); @Bean public ScrutMyDocsProperties smdProperties() throws Exception {
// Path: src/main/java/org/scrutmydocs/webapp/util/PropertyScanner.java // public class PropertyScanner { // // public static ScrutMyDocsProperties scanPropertyFile() throws IOException { // ScrutMyDocsProperties smdProps = new ScrutMyDocsProperties(); // // String userHome = System.getProperty("user.home"); // FileSystemResource resource = new FileSystemResource(userHome + "/.scrutmydocs/config/scrutmydocs.properties"); // Properties props = null; // try { // props = PropertiesLoaderUtils.loadProperties(resource); // } catch (FileNotFoundException e) { // // File does not exists ? Who cares ? // } // // if (props == null) { // // Build the file from the Classpath // FileSystemResource configDir = new FileSystemResource(userHome + "/.scrutmydocs/config/"); // ClassPathResource classPathResource = new ClassPathResource("/scrutmydocs/config/scrutmydocs.properties"); // // File from = classPathResource.getFile(); // File dest = new File(configDir.getFile(),from.getName()); // Files.createParentDirs(dest); // Files.copy(from, dest); // // props = PropertiesLoaderUtils.loadProperties(resource); // } // // if (props == null) { // throw new RuntimeException("Can not build ~/.scrutmydocs/config/scrutmydocs.properties file. Check that current user have a write access"); // } // else { // smdProps.setNodeEmbedded(getProperty(props, "node.embedded", true)); // smdProps.setClusterName(getProperty(props, "cluster.name", "scrutmydocs")); // FileSystemResource configDir = new FileSystemResource(userHome + "/.scrutmydocs/config/esdata/"); // smdProps.setPathData(getProperty(props, "path.data", configDir.getPath())); // smdProps.setNodeAdresses(getPropertyAsArray(props, "node.addresses", "localhost:9300,localhost:9301")); // // // We check some rules here : // // if node.embedded = false, we must have an array of node.adresses // if (!smdProps.isNodeEmbedded() && (smdProps.getNodeAdresses() == null || smdProps.getNodeAdresses().length < 1)) { // throw new RuntimeException("If you don't want embedded node, you MUST set node.addresses property."); // } // } // // return smdProps; // } // // private static boolean getProperty(Properties props, String path, // boolean defaultValue) { // String sValue = getProperty(props, path, Boolean.toString(defaultValue)); // if (sValue == null) // return false; // return Boolean.parseBoolean(sValue); // } // // private static String getProperty(Properties props, String path, // String defaultValue) { // return props.getProperty(path, defaultValue); // } // // private static String[] getPropertyAsArray(Properties props, String path, // String defaultValue) { // String sValue = getProperty(props, path, defaultValue); // if (sValue == null) // return null; // // // Remove spaces and split results with comma // String[] arrStr = StringUtils.commaDelimitedListToStringArray(sValue); // // return arrStr; // } // } // Path: src/main/java/org/scrutmydocs/webapp/configuration/AppConfig.java import fr.pilato.spring.elasticsearch.ElasticsearchAbstractClientFactoryBean; import fr.pilato.spring.elasticsearch.ElasticsearchClientFactoryBean; import fr.pilato.spring.elasticsearch.ElasticsearchNodeFactoryBean; import fr.pilato.spring.elasticsearch.ElasticsearchTransportClientFactoryBean; import org.elasticsearch.client.Client; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.node.Node; import org.scrutmydocs.webapp.util.PropertyScanner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.configuration; @Configuration public class AppConfig { private ESLogger logger = Loggers.getLogger(getClass().getName()); @Bean public ScrutMyDocsProperties smdProperties() throws Exception {
ScrutMyDocsProperties smdProperties = PropertyScanner.scanPropertyFile();
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/index/data/Index.java
// Path: src/main/java/org/scrutmydocs/webapp/constant/SMDSearchProperties.java // public interface SMDSearchProperties { // // public static final String INDEX_NAME = "docs"; // public static final String INDEX_TYPE_DOC = "doc"; // public static final String INDEX_TYPE_FOLDER = "folder"; // public static final String INDEX_TYPE_FS = "fsRiver"; // // public static final String DOC_FIELD_NAME = "name"; // public static final String DOC_FIELD_DATE = "postDate"; // public static final String DOC_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DOC_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DOC_FIELD_ROOT_PATH = "rootpath"; // // public static final String DIR_FIELD_NAME = "name"; // public static final String DIR_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DIR_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DIR_FIELD_ROOT_PATH = "rootpath"; // // public static final String ES_META_INDEX = "smdadmin"; // public static final String ES_META_RIVERS = "rivers"; // // }
import java.io.Serializable; import org.scrutmydocs.webapp.constant.SMDSearchProperties;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.index.data; public class Index implements Serializable { private static final long serialVersionUID = 1L; private String index = null; private String type = null; private String analyzer = null; /** * Default constructor : * <br>Builds a docs/doc index/type with default analyzer (english) */ public Index() {
// Path: src/main/java/org/scrutmydocs/webapp/constant/SMDSearchProperties.java // public interface SMDSearchProperties { // // public static final String INDEX_NAME = "docs"; // public static final String INDEX_TYPE_DOC = "doc"; // public static final String INDEX_TYPE_FOLDER = "folder"; // public static final String INDEX_TYPE_FS = "fsRiver"; // // public static final String DOC_FIELD_NAME = "name"; // public static final String DOC_FIELD_DATE = "postDate"; // public static final String DOC_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DOC_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DOC_FIELD_ROOT_PATH = "rootpath"; // // public static final String DIR_FIELD_NAME = "name"; // public static final String DIR_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DIR_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DIR_FIELD_ROOT_PATH = "rootpath"; // // public static final String ES_META_INDEX = "smdadmin"; // public static final String ES_META_RIVERS = "rivers"; // // } // Path: src/main/java/org/scrutmydocs/webapp/api/index/data/Index.java import java.io.Serializable; import org.scrutmydocs.webapp.constant.SMDSearchProperties; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.index.data; public class Index implements Serializable { private static final long serialVersionUID = 1L; private String index = null; private String type = null; private String analyzer = null; /** * Default constructor : * <br>Builds a docs/doc index/type with default analyzer (english) */ public Index() {
this(SMDSearchProperties.INDEX_NAME, SMDSearchProperties.INDEX_TYPE_DOC, null);
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/settings/rivers/basic/data/RestResponseRiver.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // }
import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.basic.data; public class RestResponseRiver extends RestResponse<BasicRiver> { private static final long serialVersionUID = 1L; public RestResponseRiver(BasicRiver doc) { super(doc); } public RestResponseRiver() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // } // Path: src/main/java/org/scrutmydocs/webapp/api/settings/rivers/basic/data/RestResponseRiver.java import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.basic.data; public class RestResponseRiver extends RestResponse<BasicRiver> { private static final long serialVersionUID = 1L; public RestResponseRiver(BasicRiver doc) { super(doc); } public RestResponseRiver() { super(); }
public RestResponseRiver(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/document/data/Document.java
// Path: src/main/java/org/scrutmydocs/webapp/constant/SMDSearchProperties.java // public interface SMDSearchProperties { // // public static final String INDEX_NAME = "docs"; // public static final String INDEX_TYPE_DOC = "doc"; // public static final String INDEX_TYPE_FOLDER = "folder"; // public static final String INDEX_TYPE_FS = "fsRiver"; // // public static final String DOC_FIELD_NAME = "name"; // public static final String DOC_FIELD_DATE = "postDate"; // public static final String DOC_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DOC_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DOC_FIELD_ROOT_PATH = "rootpath"; // // public static final String DIR_FIELD_NAME = "name"; // public static final String DIR_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DIR_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DIR_FIELD_ROOT_PATH = "rootpath"; // // public static final String ES_META_INDEX = "smdadmin"; // public static final String ES_META_RIVERS = "rivers"; // // }
import java.io.Serializable; import org.scrutmydocs.webapp.constant.SMDSearchProperties;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.document.data; public class Document implements Serializable { private static final long serialVersionUID = 1L; private String id = null; private String index = null; private String type = null; private String name = null; private String contentType = null; private String content = null; /** * Default constructor */ public Document() { } /** * @param id Technical Unique ID for this document. May be null. * @param index Index where will be stored your document (E.g.: mycompany) * @param type Functionnal type of your document (E.g.: mybusinessunit) * @param name Document fancy name * @param contentType File ContentType. May be null. * @param content Base64 encoded file content */ public Document(String id, String index, String type, String name, String contentType, String content) { super(); this.id = id; this.index = index; this.type = type; this.name = name; this.contentType = contentType; this.content = content; } /** * @param id Technical Unique ID for this document. May be null. * @param index Index where will be stored your document (E.g.: mycompany) * @param type Functionnal type of your document (E.g.: mybusinessunit) * @param name Document fancy name * @param content Base64 encoded file content */ public Document(String id, String index, String type, String name, String content) { this(id, index, type, name, null, content); } /** * @param index Index where will be stored your document (E.g.: mycompany) * @param type Functionnal type of your document (E.g.: mybusinessunit) * @param name Document fancy name * @param content Base64 encoded file content */ public Document(String index, String type, String name, String content) { this(null, index, type, name, null, content); } /** * @param name Document fancy name * @param content Base64 encoded file content */ public Document(String name, String content) {
// Path: src/main/java/org/scrutmydocs/webapp/constant/SMDSearchProperties.java // public interface SMDSearchProperties { // // public static final String INDEX_NAME = "docs"; // public static final String INDEX_TYPE_DOC = "doc"; // public static final String INDEX_TYPE_FOLDER = "folder"; // public static final String INDEX_TYPE_FS = "fsRiver"; // // public static final String DOC_FIELD_NAME = "name"; // public static final String DOC_FIELD_DATE = "postDate"; // public static final String DOC_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DOC_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DOC_FIELD_ROOT_PATH = "rootpath"; // // public static final String DIR_FIELD_NAME = "name"; // public static final String DIR_FIELD_PATH_ENCODED = "pathEncoded"; // public static final String DIR_FIELD_VIRTUAL_PATH = "virtualpath"; // public static final String DIR_FIELD_ROOT_PATH = "rootpath"; // // public static final String ES_META_INDEX = "smdadmin"; // public static final String ES_META_RIVERS = "rivers"; // // } // Path: src/main/java/org/scrutmydocs/webapp/api/document/data/Document.java import java.io.Serializable; import org.scrutmydocs.webapp.constant.SMDSearchProperties; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.document.data; public class Document implements Serializable { private static final long serialVersionUID = 1L; private String id = null; private String index = null; private String type = null; private String name = null; private String contentType = null; private String content = null; /** * Default constructor */ public Document() { } /** * @param id Technical Unique ID for this document. May be null. * @param index Index where will be stored your document (E.g.: mycompany) * @param type Functionnal type of your document (E.g.: mybusinessunit) * @param name Document fancy name * @param contentType File ContentType. May be null. * @param content Base64 encoded file content */ public Document(String id, String index, String type, String name, String contentType, String content) { super(); this.id = id; this.index = index; this.type = type; this.name = name; this.contentType = contentType; this.content = content; } /** * @param id Technical Unique ID for this document. May be null. * @param index Index where will be stored your document (E.g.: mycompany) * @param type Functionnal type of your document (E.g.: mybusinessunit) * @param name Document fancy name * @param content Base64 encoded file content */ public Document(String id, String index, String type, String name, String content) { this(id, index, type, name, null, content); } /** * @param index Index where will be stored your document (E.g.: mycompany) * @param type Functionnal type of your document (E.g.: mybusinessunit) * @param name Document fancy name * @param content Base64 encoded file content */ public Document(String index, String type, String name, String content) { this(null, index, type, name, null, content); } /** * @param name Document fancy name * @param content Base64 encoded file content */ public Document(String name, String content) {
this(null, SMDSearchProperties.INDEX_NAME, SMDSearchProperties.INDEX_TYPE_DOC, name, null, content);
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/settings/rivers/fs/data/RestResponseFSRiver.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // }
import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.fs.data; public class RestResponseFSRiver extends RestResponse<FSRiver> { private static final long serialVersionUID = 1L; public RestResponseFSRiver(FSRiver river) { super(river); } public RestResponseFSRiver() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // } // Path: src/main/java/org/scrutmydocs/webapp/api/settings/rivers/fs/data/RestResponseFSRiver.java import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.settings.rivers.fs.data; public class RestResponseFSRiver extends RestResponse<FSRiver> { private static final long serialVersionUID = 1L; public RestResponseFSRiver(FSRiver river) { super(river); } public RestResponseFSRiver() { super(); }
public RestResponseFSRiver(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/index/data/RestResponseIndex.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // }
import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.index.data; public class RestResponseIndex extends RestResponse<Index> { private static final long serialVersionUID = 1L; public RestResponseIndex(Index doc) { super(doc); } public RestResponseIndex() { super(); }
// Path: src/main/java/org/scrutmydocs/webapp/api/common/RestAPIException.java // public class RestAPIException extends Exception { // private static final long serialVersionUID = 1L; // // public RestAPIException(String message) { // super(message); // } // // public RestAPIException(Exception e) { // super(e.getMessage()); // } // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponse.java // public class RestResponse<T> implements Serializable { // // private static final long serialVersionUID = 1L; // // private boolean ok; // private String errors[]; // private T object; // // /** // * Default constructor : we suppose here that ok = true // */ // public RestResponse() { // this.ok = true; // } // // /** // * We can get an object back, so there is no error and ok=true // * @param object // */ // public RestResponse(T object) { // this.object = object; // this.ok = true; // } // // // /** // * We build a response when we have errors // * @param errors // */ // public RestResponse(String[] errors) { // this.errors = errors; // this.ok = false; // } // // /** // * We build a response when we have a single exception // * @param e // */ // public RestResponse(RestAPIException e) { // addError(e); // } // // public boolean isOk() { // return ok; // } // // public void setOk(boolean ok) { // this.ok = ok; // } // // public String[] getErrors() { // return errors; // } // // public void setErrors(String[] errors) { // this.errors = errors; // } // // public Object getObject() { // return object; // } // // public void setObject(T object) { // this.object = object; // } // // /** // * Add an error to the error list // * @param e // */ // public void addError(RestAPIException e) { // this.ok = false; // Collection<String> errs = new ArrayList<String>(); // if (this.errors != null) Collections.addAll(errs, this.errors); // errs.add(e.getMessage()); // this.errors = (String[])errs.toArray(new String[errs.size()]); // } // } // Path: src/main/java/org/scrutmydocs/webapp/api/index/data/RestResponseIndex.java import org.scrutmydocs.webapp.api.common.RestAPIException; import org.scrutmydocs.webapp.api.common.data.RestResponse; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.index.data; public class RestResponseIndex extends RestResponse<Index> { private static final long serialVersionUID = 1L; public RestResponseIndex(Index doc) { super(doc); } public RestResponseIndex() { super(); }
public RestResponseIndex(RestAPIException e) {
scrutmydocs/scrutmydocs
src/main/java/org/scrutmydocs/webapp/api/common/facade/WelcomeApi.java
// Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Api.java // public class Api implements Serializable { // private static final long serialVersionUID = 1L; // // private String url = null; // private String method = null; // private String description = null; // // public Api() { // } // // /** // * @param url // * @param method // * @param description // */ // public Api(String url, String method, String description) { // super(); // this.url = url; // this.method = method; // this.description = description; // } // // // // /** // * @return the url // */ // public String getUrl() { // return url; // } // /** // * @param url the url to set // */ // public void setUrl(String url) { // this.url = url; // } // /** // * @return the method // */ // public String getMethod() { // return method; // } // /** // * @param method the method to set // */ // public void setMethod(String method) { // this.method = method; // } // /** // * @return the description // */ // public String getDescription() { // return description; // } // /** // * @param description the description to set // */ // public void setDescription(String description) { // this.description = description; // } // // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java // public class RestResponseWelcome extends RestResponse<Welcome> { // private static final long serialVersionUID = 1L; // // public RestResponseWelcome(Welcome doc) { // super(doc); // } // // public RestResponseWelcome() { // super(); // } // // public RestResponseWelcome(RestAPIException e) { // super(e); // } // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Welcome.java // public class Welcome implements Serializable { // private static final long serialVersionUID = 1L; // // private String version = null; // private String message = null; // private Api[] apis = null; // // /** // * Default constructor : // */ // public Welcome() { // version = "0.0.1-SNAPSHOT"; // apis = new Api[4]; // apis[0] = new Api("/", "GET", "This API"); // apis[1] = new Api("_help", "GET", "Should give you help on each APIs."); // apis[2] = new Api("/doc", "PUT/GET/DELETE", "Manage documents."); // apis[3] = new Api("/index", "POST/DELETE", "Manage Indices"); // } // // /** // * @param message Message to display to user // */ // public Welcome(String message) { // this(); // this.message = message; // } // // /** // * @return the version // */ // public String getVersion() { // return version; // } // // /** // * @param version the version to set // */ // public void setVersion(String version) { // this.version = version; // } // // /** // * @return the message // */ // public String getMessage() { // return message; // } // // /** // * @param message the message to set // */ // public void setMessage(String message) { // this.message = message; // } // // /** // * @return the apis // */ // public Api[] getApis() { // return apis; // } // // /** // * @param apis the apis to set // */ // public void setApis(Api[] apis) { // this.apis = apis; // } // // // // }
import org.scrutmydocs.webapp.api.common.data.Api; import org.scrutmydocs.webapp.api.common.data.RestResponseWelcome; import org.scrutmydocs.webapp.api.common.data.Welcome; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody;
/* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.facade; @Controller @RequestMapping("/") public class WelcomeApi extends CommonBaseApi { @Override
// Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Api.java // public class Api implements Serializable { // private static final long serialVersionUID = 1L; // // private String url = null; // private String method = null; // private String description = null; // // public Api() { // } // // /** // * @param url // * @param method // * @param description // */ // public Api(String url, String method, String description) { // super(); // this.url = url; // this.method = method; // this.description = description; // } // // // // /** // * @return the url // */ // public String getUrl() { // return url; // } // /** // * @param url the url to set // */ // public void setUrl(String url) { // this.url = url; // } // /** // * @return the method // */ // public String getMethod() { // return method; // } // /** // * @param method the method to set // */ // public void setMethod(String method) { // this.method = method; // } // /** // * @return the description // */ // public String getDescription() { // return description; // } // /** // * @param description the description to set // */ // public void setDescription(String description) { // this.description = description; // } // // // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/RestResponseWelcome.java // public class RestResponseWelcome extends RestResponse<Welcome> { // private static final long serialVersionUID = 1L; // // public RestResponseWelcome(Welcome doc) { // super(doc); // } // // public RestResponseWelcome() { // super(); // } // // public RestResponseWelcome(RestAPIException e) { // super(e); // } // } // // Path: src/main/java/org/scrutmydocs/webapp/api/common/data/Welcome.java // public class Welcome implements Serializable { // private static final long serialVersionUID = 1L; // // private String version = null; // private String message = null; // private Api[] apis = null; // // /** // * Default constructor : // */ // public Welcome() { // version = "0.0.1-SNAPSHOT"; // apis = new Api[4]; // apis[0] = new Api("/", "GET", "This API"); // apis[1] = new Api("_help", "GET", "Should give you help on each APIs."); // apis[2] = new Api("/doc", "PUT/GET/DELETE", "Manage documents."); // apis[3] = new Api("/index", "POST/DELETE", "Manage Indices"); // } // // /** // * @param message Message to display to user // */ // public Welcome(String message) { // this(); // this.message = message; // } // // /** // * @return the version // */ // public String getVersion() { // return version; // } // // /** // * @param version the version to set // */ // public void setVersion(String version) { // this.version = version; // } // // /** // * @return the message // */ // public String getMessage() { // return message; // } // // /** // * @param message the message to set // */ // public void setMessage(String message) { // this.message = message; // } // // /** // * @return the apis // */ // public Api[] getApis() { // return apis; // } // // /** // * @param apis the apis to set // */ // public void setApis(Api[] apis) { // this.apis = apis; // } // // // // } // Path: src/main/java/org/scrutmydocs/webapp/api/common/facade/WelcomeApi.java import org.scrutmydocs.webapp.api.common.data.Api; import org.scrutmydocs.webapp.api.common.data.RestResponseWelcome; import org.scrutmydocs.webapp.api.common.data.Welcome; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; /* * Licensed to scrutmydocs.org (the "Author") under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. Author licenses this * file to you 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. */ package org.scrutmydocs.webapp.api.common.facade; @Controller @RequestMapping("/") public class WelcomeApi extends CommonBaseApi { @Override
public Api[] helpApiList() {
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/repo/java/index/JavaIndexKey.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/java/base/JavaGroup.java // public class JavaGroup // { // private String group; // // private JavaGroup(String group) // { // this.group = group; // } // // /** // * Returns the dot-delimited group. // * @return Group using . (e.g. org.blah.things) // */ // public String getGroup() // { // return group; // } // // /** // * Sometimes we want to return the Java Group as a path-based structure, // * either for storage purposes or querying a proxy. // * @return Group using / instead of . (e.g. org/blah/things) // */ // public String getGroupAsPath() // { // return group.replace(".", "/"); // } // // /** // * Used to generate a JavaGroup from a slash-delimited string // * @param groupString Changing /org/blah/things -> org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup slashDelimited(String groupString) // { // return new JavaGroup(groupString.replace('/', '.')); // } // // /** // * Used to generate a JavaGroup from a dot-delimited string // * @param groupString org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup dotDelimited(String groupString) // { // return new JavaGroup(groupString); // } // // @Override // public String toString() // { // return getGroup(); // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // JavaGroup other = (JavaGroup) obj; // if (group == null) // { // if (other.group != null) // { // return false; // } // } // else if (!group.equals(other.group)) // { // return false; // } // return true; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((group == null) ? 0 : group.hashCode()); // return result; // } // // }
import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.repo.java.base.JavaGroup; import java.util.Objects;
package com.spedge.hangar.repo.java.index; public class JavaIndexKey extends IndexKey {
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/java/base/JavaGroup.java // public class JavaGroup // { // private String group; // // private JavaGroup(String group) // { // this.group = group; // } // // /** // * Returns the dot-delimited group. // * @return Group using . (e.g. org.blah.things) // */ // public String getGroup() // { // return group; // } // // /** // * Sometimes we want to return the Java Group as a path-based structure, // * either for storage purposes or querying a proxy. // * @return Group using / instead of . (e.g. org/blah/things) // */ // public String getGroupAsPath() // { // return group.replace(".", "/"); // } // // /** // * Used to generate a JavaGroup from a slash-delimited string // * @param groupString Changing /org/blah/things -> org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup slashDelimited(String groupString) // { // return new JavaGroup(groupString.replace('/', '.')); // } // // /** // * Used to generate a JavaGroup from a dot-delimited string // * @param groupString org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup dotDelimited(String groupString) // { // return new JavaGroup(groupString); // } // // @Override // public String toString() // { // return getGroup(); // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // JavaGroup other = (JavaGroup) obj; // if (group == null) // { // if (other.group != null) // { // return false; // } // } // else if (!group.equals(other.group)) // { // return false; // } // return true; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((group == null) ? 0 : group.hashCode()); // return result; // } // // } // Path: hangar-api/src/main/java/com/spedge/hangar/repo/java/index/JavaIndexKey.java import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.repo.java.base.JavaGroup; import java.util.Objects; package com.spedge.hangar.repo.java.index; public class JavaIndexKey extends IndexKey {
private JavaGroup group;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/repo/java/index/JavaIndexKey.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/java/base/JavaGroup.java // public class JavaGroup // { // private String group; // // private JavaGroup(String group) // { // this.group = group; // } // // /** // * Returns the dot-delimited group. // * @return Group using . (e.g. org.blah.things) // */ // public String getGroup() // { // return group; // } // // /** // * Sometimes we want to return the Java Group as a path-based structure, // * either for storage purposes or querying a proxy. // * @return Group using / instead of . (e.g. org/blah/things) // */ // public String getGroupAsPath() // { // return group.replace(".", "/"); // } // // /** // * Used to generate a JavaGroup from a slash-delimited string // * @param groupString Changing /org/blah/things -> org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup slashDelimited(String groupString) // { // return new JavaGroup(groupString.replace('/', '.')); // } // // /** // * Used to generate a JavaGroup from a dot-delimited string // * @param groupString org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup dotDelimited(String groupString) // { // return new JavaGroup(groupString); // } // // @Override // public String toString() // { // return getGroup(); // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // JavaGroup other = (JavaGroup) obj; // if (group == null) // { // if (other.group != null) // { // return false; // } // } // else if (!group.equals(other.group)) // { // return false; // } // return true; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((group == null) ? 0 : group.hashCode()); // return result; // } // // }
import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.repo.java.base.JavaGroup; import java.util.Objects;
package com.spedge.hangar.repo.java.index; public class JavaIndexKey extends IndexKey { private JavaGroup group; private String artifact = ""; private String version = ""; /** * <p>Creates a Key to be used to register an IndexArtifact with * the Index layer. </p> * * @param type Type of Repository this Artifact will be stored from. * @param group Group of the Artifact * @param artifact Name of the Artifact * @param version Version of the Artifact */
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/java/base/JavaGroup.java // public class JavaGroup // { // private String group; // // private JavaGroup(String group) // { // this.group = group; // } // // /** // * Returns the dot-delimited group. // * @return Group using . (e.g. org.blah.things) // */ // public String getGroup() // { // return group; // } // // /** // * Sometimes we want to return the Java Group as a path-based structure, // * either for storage purposes or querying a proxy. // * @return Group using / instead of . (e.g. org/blah/things) // */ // public String getGroupAsPath() // { // return group.replace(".", "/"); // } // // /** // * Used to generate a JavaGroup from a slash-delimited string // * @param groupString Changing /org/blah/things -> org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup slashDelimited(String groupString) // { // return new JavaGroup(groupString.replace('/', '.')); // } // // /** // * Used to generate a JavaGroup from a dot-delimited string // * @param groupString org.blah.things // * @return A new JavaGroup with the correct format. // */ // public static JavaGroup dotDelimited(String groupString) // { // return new JavaGroup(groupString); // } // // @Override // public String toString() // { // return getGroup(); // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // JavaGroup other = (JavaGroup) obj; // if (group == null) // { // if (other.group != null) // { // return false; // } // } // else if (!group.equals(other.group)) // { // return false; // } // return true; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((group == null) ? 0 : group.hashCode()); // return result; // } // // } // Path: hangar-api/src/main/java/com/spedge/hangar/repo/java/index/JavaIndexKey.java import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.repo.java.base.JavaGroup; import java.util.Objects; package com.spedge.hangar.repo.java.index; public class JavaIndexKey extends IndexKey { private JavaGroup group; private String artifact = ""; private String version = ""; /** * <p>Creates a Key to be used to register an IndexArtifact with * the Index layer. </p> * * @param type Type of Repository this Artifact will be stored from. * @param group Group of the Artifact * @param artifact Name of the Artifact * @param version Version of the Artifact */
public JavaIndexKey(RepositoryType type, JavaGroup group, String artifact, String version)
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/Hangar.java
// Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java // public class HangarConfiguration extends Configuration // { // // @JsonProperty // private IStorage storage; // // @JsonProperty // private IIndex artifactIndex; // // @NotEmpty // @JsonProperty // private List<IRepository> repositories; // // public List<IRepository> getRepositories() // { // return repositories; // } // // public void setRepositories(List<IRepository> repositories) // { // this.repositories = repositories; // } // // public IStorage getStorage() // { // return storage; // } // // public void setStorage(IStorage storage) // { // this.storage = storage; // } // // public IIndex getIndex() // { // return artifactIndex; // } // // public void setIndex(IIndex index) // { // this.artifactIndex = index; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarInjector.java // public class HangarInjector extends AbstractModule // { // @Override // protected void configure() // { // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/requests/TestRequest.java // @Path("/test") // public class TestRequest // { // /** // * Simple way of looking at the headers of a request. // * Handy when working with Dropwizard. // * // * @param httpHeaders Headers of the request // * @return Responses // */ // @PUT // @Path("/headers") // public Response testThing(@Context HttpHeaders httpHeaders) // { // for (MediaType mt : httpHeaders.getAcceptableMediaTypes()) // { // System.out.println("MediaType : " + mt.getType()); // } // // return Response.ok().build(); // } // }
import com.google.inject.Guice; import com.google.inject.Injector; import com.spedge.hangar.config.HangarConfiguration; import com.spedge.hangar.config.HangarInjector; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.requests.TestRequest; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import java.util.List;
package com.spedge.hangar; /** * The main entry point for the Hangar application. * * @author Spedge * */ public class Hangar extends Application<HangarConfiguration> { public static void main(String[] args) throws Exception {
// Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java // public class HangarConfiguration extends Configuration // { // // @JsonProperty // private IStorage storage; // // @JsonProperty // private IIndex artifactIndex; // // @NotEmpty // @JsonProperty // private List<IRepository> repositories; // // public List<IRepository> getRepositories() // { // return repositories; // } // // public void setRepositories(List<IRepository> repositories) // { // this.repositories = repositories; // } // // public IStorage getStorage() // { // return storage; // } // // public void setStorage(IStorage storage) // { // this.storage = storage; // } // // public IIndex getIndex() // { // return artifactIndex; // } // // public void setIndex(IIndex index) // { // this.artifactIndex = index; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarInjector.java // public class HangarInjector extends AbstractModule // { // @Override // protected void configure() // { // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/requests/TestRequest.java // @Path("/test") // public class TestRequest // { // /** // * Simple way of looking at the headers of a request. // * Handy when working with Dropwizard. // * // * @param httpHeaders Headers of the request // * @return Responses // */ // @PUT // @Path("/headers") // public Response testThing(@Context HttpHeaders httpHeaders) // { // for (MediaType mt : httpHeaders.getAcceptableMediaTypes()) // { // System.out.println("MediaType : " + mt.getType()); // } // // return Response.ok().build(); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/Hangar.java import com.google.inject.Guice; import com.google.inject.Injector; import com.spedge.hangar.config.HangarConfiguration; import com.spedge.hangar.config.HangarInjector; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.requests.TestRequest; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import java.util.List; package com.spedge.hangar; /** * The main entry point for the Hangar application. * * @author Spedge * */ public class Hangar extends Application<HangarConfiguration> { public static void main(String[] args) throws Exception {
Injector injector = Guice.createInjector(new HangarInjector());
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/Hangar.java
// Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java // public class HangarConfiguration extends Configuration // { // // @JsonProperty // private IStorage storage; // // @JsonProperty // private IIndex artifactIndex; // // @NotEmpty // @JsonProperty // private List<IRepository> repositories; // // public List<IRepository> getRepositories() // { // return repositories; // } // // public void setRepositories(List<IRepository> repositories) // { // this.repositories = repositories; // } // // public IStorage getStorage() // { // return storage; // } // // public void setStorage(IStorage storage) // { // this.storage = storage; // } // // public IIndex getIndex() // { // return artifactIndex; // } // // public void setIndex(IIndex index) // { // this.artifactIndex = index; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarInjector.java // public class HangarInjector extends AbstractModule // { // @Override // protected void configure() // { // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/requests/TestRequest.java // @Path("/test") // public class TestRequest // { // /** // * Simple way of looking at the headers of a request. // * Handy when working with Dropwizard. // * // * @param httpHeaders Headers of the request // * @return Responses // */ // @PUT // @Path("/headers") // public Response testThing(@Context HttpHeaders httpHeaders) // { // for (MediaType mt : httpHeaders.getAcceptableMediaTypes()) // { // System.out.println("MediaType : " + mt.getType()); // } // // return Response.ok().build(); // } // }
import com.google.inject.Guice; import com.google.inject.Injector; import com.spedge.hangar.config.HangarConfiguration; import com.spedge.hangar.config.HangarInjector; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.requests.TestRequest; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import java.util.List;
package com.spedge.hangar; /** * The main entry point for the Hangar application. * * @author Spedge * */ public class Hangar extends Application<HangarConfiguration> { public static void main(String[] args) throws Exception { Injector injector = Guice.createInjector(new HangarInjector()); injector.getInstance(Hangar.class).run(args); } @Override public String getName() { return "hangar"; } @Override public void initialize(Bootstrap<HangarConfiguration> bootstrap) { // nothing to do yet } @Override public void run(HangarConfiguration configuration, Environment environment) throws Exception { // // When the application starts, we create the repositories we want to // manage // from the configuration file that was passed in at startup.
// Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java // public class HangarConfiguration extends Configuration // { // // @JsonProperty // private IStorage storage; // // @JsonProperty // private IIndex artifactIndex; // // @NotEmpty // @JsonProperty // private List<IRepository> repositories; // // public List<IRepository> getRepositories() // { // return repositories; // } // // public void setRepositories(List<IRepository> repositories) // { // this.repositories = repositories; // } // // public IStorage getStorage() // { // return storage; // } // // public void setStorage(IStorage storage) // { // this.storage = storage; // } // // public IIndex getIndex() // { // return artifactIndex; // } // // public void setIndex(IIndex index) // { // this.artifactIndex = index; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarInjector.java // public class HangarInjector extends AbstractModule // { // @Override // protected void configure() // { // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/requests/TestRequest.java // @Path("/test") // public class TestRequest // { // /** // * Simple way of looking at the headers of a request. // * Handy when working with Dropwizard. // * // * @param httpHeaders Headers of the request // * @return Responses // */ // @PUT // @Path("/headers") // public Response testThing(@Context HttpHeaders httpHeaders) // { // for (MediaType mt : httpHeaders.getAcceptableMediaTypes()) // { // System.out.println("MediaType : " + mt.getType()); // } // // return Response.ok().build(); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/Hangar.java import com.google.inject.Guice; import com.google.inject.Injector; import com.spedge.hangar.config.HangarConfiguration; import com.spedge.hangar.config.HangarInjector; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.requests.TestRequest; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import java.util.List; package com.spedge.hangar; /** * The main entry point for the Hangar application. * * @author Spedge * */ public class Hangar extends Application<HangarConfiguration> { public static void main(String[] args) throws Exception { Injector injector = Guice.createInjector(new HangarInjector()); injector.getInstance(Hangar.class).run(args); } @Override public String getName() { return "hangar"; } @Override public void initialize(Bootstrap<HangarConfiguration> bootstrap) { // nothing to do yet } @Override public void run(HangarConfiguration configuration, Environment environment) throws Exception { // // When the application starts, we create the repositories we want to // manage // from the configuration file that was passed in at startup.
List<IRepository> repos = configuration.getRepositories();
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/Hangar.java
// Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java // public class HangarConfiguration extends Configuration // { // // @JsonProperty // private IStorage storage; // // @JsonProperty // private IIndex artifactIndex; // // @NotEmpty // @JsonProperty // private List<IRepository> repositories; // // public List<IRepository> getRepositories() // { // return repositories; // } // // public void setRepositories(List<IRepository> repositories) // { // this.repositories = repositories; // } // // public IStorage getStorage() // { // return storage; // } // // public void setStorage(IStorage storage) // { // this.storage = storage; // } // // public IIndex getIndex() // { // return artifactIndex; // } // // public void setIndex(IIndex index) // { // this.artifactIndex = index; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarInjector.java // public class HangarInjector extends AbstractModule // { // @Override // protected void configure() // { // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/requests/TestRequest.java // @Path("/test") // public class TestRequest // { // /** // * Simple way of looking at the headers of a request. // * Handy when working with Dropwizard. // * // * @param httpHeaders Headers of the request // * @return Responses // */ // @PUT // @Path("/headers") // public Response testThing(@Context HttpHeaders httpHeaders) // { // for (MediaType mt : httpHeaders.getAcceptableMediaTypes()) // { // System.out.println("MediaType : " + mt.getType()); // } // // return Response.ok().build(); // } // }
import com.google.inject.Guice; import com.google.inject.Injector; import com.spedge.hangar.config.HangarConfiguration; import com.spedge.hangar.config.HangarInjector; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.requests.TestRequest; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import java.util.List;
package com.spedge.hangar; /** * The main entry point for the Hangar application. * * @author Spedge * */ public class Hangar extends Application<HangarConfiguration> { public static void main(String[] args) throws Exception { Injector injector = Guice.createInjector(new HangarInjector()); injector.getInstance(Hangar.class).run(args); } @Override public String getName() { return "hangar"; } @Override public void initialize(Bootstrap<HangarConfiguration> bootstrap) { // nothing to do yet } @Override public void run(HangarConfiguration configuration, Environment environment) throws Exception { // // When the application starts, we create the repositories we want to // manage // from the configuration file that was passed in at startup. List<IRepository> repos = configuration.getRepositories(); // Once we've got the list, we want to register all of the healthchecks // that come // with these configurations - as well as registering the repository // endpoints themselves. for (IRepository repo : repos) { repo.loadRepository(configuration, environment); for (String key : repo.getHealthChecks().keySet()) { environment.healthChecks().register(key, repo.getHealthChecks().get(key)); } environment.jersey().register(repo); } // This is a path that I can hit to see the details of a request, // something I've found particularly hard to capture with some of the // crazy multi-requests that go on in dependency management. // // TODO : Allow this only in debug mode.
// Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java // public class HangarConfiguration extends Configuration // { // // @JsonProperty // private IStorage storage; // // @JsonProperty // private IIndex artifactIndex; // // @NotEmpty // @JsonProperty // private List<IRepository> repositories; // // public List<IRepository> getRepositories() // { // return repositories; // } // // public void setRepositories(List<IRepository> repositories) // { // this.repositories = repositories; // } // // public IStorage getStorage() // { // return storage; // } // // public void setStorage(IStorage storage) // { // this.storage = storage; // } // // public IIndex getIndex() // { // return artifactIndex; // } // // public void setIndex(IIndex index) // { // this.artifactIndex = index; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarInjector.java // public class HangarInjector extends AbstractModule // { // @Override // protected void configure() // { // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/requests/TestRequest.java // @Path("/test") // public class TestRequest // { // /** // * Simple way of looking at the headers of a request. // * Handy when working with Dropwizard. // * // * @param httpHeaders Headers of the request // * @return Responses // */ // @PUT // @Path("/headers") // public Response testThing(@Context HttpHeaders httpHeaders) // { // for (MediaType mt : httpHeaders.getAcceptableMediaTypes()) // { // System.out.println("MediaType : " + mt.getType()); // } // // return Response.ok().build(); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/Hangar.java import com.google.inject.Guice; import com.google.inject.Injector; import com.spedge.hangar.config.HangarConfiguration; import com.spedge.hangar.config.HangarInjector; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.requests.TestRequest; import io.dropwizard.Application; import io.dropwizard.setup.Bootstrap; import io.dropwizard.setup.Environment; import java.util.List; package com.spedge.hangar; /** * The main entry point for the Hangar application. * * @author Spedge * */ public class Hangar extends Application<HangarConfiguration> { public static void main(String[] args) throws Exception { Injector injector = Guice.createInjector(new HangarInjector()); injector.getInstance(Hangar.class).run(args); } @Override public String getName() { return "hangar"; } @Override public void initialize(Bootstrap<HangarConfiguration> bootstrap) { // nothing to do yet } @Override public void run(HangarConfiguration configuration, Environment environment) throws Exception { // // When the application starts, we create the repositories we want to // manage // from the configuration file that was passed in at startup. List<IRepository> repos = configuration.getRepositories(); // Once we've got the list, we want to register all of the healthchecks // that come // with these configurations - as well as registering the repository // endpoints themselves. for (IRepository repo : repos) { repo.loadRepository(configuration, environment); for (String key : repo.getHealthChecks().keySet()) { environment.healthChecks().register(key, repo.getHealthChecks().get(key)); } environment.jersey().register(repo); } // This is a path that I can hit to see the details of a request, // something I've found particularly hard to capture with some of the // crazy multi-requests that go on in dependency management. // // TODO : Allow this only in debug mode.
environment.jersey().register(new TestRequest());
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/repo/python/PythonStorageTranslator.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java // public interface IStorageTranslator // { // String[] getDelimiters(); // // IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException; // // IndexArtifact generateIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // RepositoryType getType(); // // List<IndexKey> getLocalStorageKeys(Path sourcePath) throws LocalStorageException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // }
import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.IStorageTranslator; import com.spedge.hangar.storage.local.LocalStorageException;
package com.spedge.hangar.repo.python; public class PythonStorageTranslator implements IStorageTranslator { private final String[] delimiters = new String[]{};
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java // public interface IStorageTranslator // { // String[] getDelimiters(); // // IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException; // // IndexArtifact generateIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // RepositoryType getType(); // // List<IndexKey> getLocalStorageKeys(Path sourcePath) throws LocalStorageException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/repo/python/PythonStorageTranslator.java import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.IStorageTranslator; import com.spedge.hangar.storage.local.LocalStorageException; package com.spedge.hangar.repo.python; public class PythonStorageTranslator implements IStorageTranslator { private final String[] delimiters = new String[]{};
private RepositoryType type;
Spedge/hangar
hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // }
import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils;
package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // } // Path: hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils; package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test
public void testAddArtifact() throws IndexConfictException
Spedge/hangar
hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // }
import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils;
package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test public void testAddArtifact() throws IndexConfictException { // Add an artifact.
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // } // Path: hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils; package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test public void testAddArtifact() throws IndexConfictException { // Add an artifact.
index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact());
Spedge/hangar
hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // }
import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils;
package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test public void testAddArtifact() throws IndexConfictException { // Add an artifact. index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); // Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } @Test
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // } // Path: hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils; package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test public void testAddArtifact() throws IndexConfictException { // Add an artifact. index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); // Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } @Test
public void testReservedArtifact() throws StorageException, IndexConfictException
Spedge/hangar
hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // }
import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils;
package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test public void testAddArtifact() throws IndexConfictException { // Add an artifact. index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); // Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } @Test public void testReservedArtifact() throws StorageException, IndexConfictException { // Add a reserved artifact
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/StorageException.java // public abstract class StorageException extends Exception // { // public StorageException(Exception exception) // { // super(exception); // } // // private static final long serialVersionUID = -4510536728418574349L; // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // } // Path: hangar-api/src/test/java/com/spedge/hangar/index/memory/TestInMemoryIndex.java import static org.junit.Assert.assertEquals; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.storage.StorageException; import com.spedge.hangar.testutils.IndexUtils; package com.spedge.hangar.index.memory; public class TestInMemoryIndex { InMemoryIndex index; @Before public void setupIndex() { index = new InMemoryIndex(); } @Test public void testAddArtifact() throws IndexConfictException { // Add an artifact. index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); // Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } @Test public void testReservedArtifact() throws StorageException, IndexConfictException { // Add a reserved artifact
ReservedArtifact ra = index.addReservationKey(IndexUtils.TEST2.getKey());
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java
// Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // }
import com.spedge.hangar.repo.RepositoryType;
package com.spedge.hangar.index; public class IndexKey { private String key;
// Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java import com.spedge.hangar.repo.RepositoryType; package com.spedge.hangar.index; public class IndexKey { private String key;
private RepositoryType type = RepositoryType.UNKNOWN;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // }
import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException;
package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters();
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException; package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters();
IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // }
import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException;
package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters();
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException; package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters();
IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // }
import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException;
package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters(); IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException;
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException; package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters(); IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException;
IndexArtifact generateIndexArtifact(IndexKey key, String uploadPath) throws IndexException;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // }
import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException;
package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters(); IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException; IndexArtifact generateIndexArtifact(IndexKey key, String uploadPath) throws IndexException;
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException; package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters(); IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException; IndexArtifact generateIndexArtifact(IndexKey key, String uploadPath) throws IndexException;
RepositoryType getType();
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // }
import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException;
package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters(); IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException; IndexArtifact generateIndexArtifact(IndexKey key, String uploadPath) throws IndexException; RepositoryType getType();
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/local/LocalStorageException.java // public class LocalStorageException extends StorageException // { // private static final long serialVersionUID = -828019302534255082L; // // public LocalStorageException(Exception exception) // { // super(exception); // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorageTranslator.java import java.nio.file.Path; import java.util.List; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; import com.spedge.hangar.storage.local.LocalStorageException; package com.spedge.hangar.storage; public interface IStorageTranslator { String[] getDelimiters(); IndexKey generateIndexKey(String prefixPath, String prefix) throws IndexException; IndexArtifact generateIndexArtifact(IndexKey key, String uploadPath) throws IndexException; RepositoryType getType();
List<IndexKey> getLocalStorageKeys(Path sourcePath) throws LocalStorageException;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/Storage.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // }
import java.io.IOException; import java.util.HashMap; import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey;
package com.spedge.hangar.storage; public abstract class Storage implements IStorage { protected final Logger logger = LoggerFactory.getLogger(Storage.class); private HashMap<String, IStorageTranslator> paths = new HashMap<String, IStorageTranslator>(); @NotEmpty private String path; @JsonProperty public String getPath() { return path; } @JsonProperty public void setPath(String path) throws IOException { this.path = path; } protected void addPathTranslator(IStorageTranslator st, String path) { paths.put(path, st); } public IStorageTranslator getStorageTranslator(String prefixPath) { return paths.get(prefixPath); } @Override
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/Storage.java import java.io.IOException; import java.util.HashMap; import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; package com.spedge.hangar.storage; public abstract class Storage implements IStorage { protected final Logger logger = LoggerFactory.getLogger(Storage.class); private HashMap<String, IStorageTranslator> paths = new HashMap<String, IStorageTranslator>(); @NotEmpty private String path; @JsonProperty public String getPath() { return path; } @JsonProperty public void setPath(String path) throws IOException { this.path = path; } protected void addPathTranslator(IStorageTranslator st, String path) { paths.put(path, st); } public IStorageTranslator getStorageTranslator(String prefixPath) { return paths.get(prefixPath); } @Override
public IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/Storage.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // }
import java.io.IOException; import java.util.HashMap; import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey;
package com.spedge.hangar.storage; public abstract class Storage implements IStorage { protected final Logger logger = LoggerFactory.getLogger(Storage.class); private HashMap<String, IStorageTranslator> paths = new HashMap<String, IStorageTranslator>(); @NotEmpty private String path; @JsonProperty public String getPath() { return path; } @JsonProperty public void setPath(String path) throws IOException { this.path = path; } protected void addPathTranslator(IStorageTranslator st, String path) { paths.put(path, st); } public IStorageTranslator getStorageTranslator(String prefixPath) { return paths.get(prefixPath); } @Override
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/Storage.java import java.io.IOException; import java.util.HashMap; import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; package com.spedge.hangar.storage; public abstract class Storage implements IStorage { protected final Logger logger = LoggerFactory.getLogger(Storage.class); private HashMap<String, IStorageTranslator> paths = new HashMap<String, IStorageTranslator>(); @NotEmpty private String path; @JsonProperty public String getPath() { return path; } @JsonProperty public void setPath(String path) throws IOException { this.path = path; } protected void addPathTranslator(IStorageTranslator st, String path) { paths.put(path, st); } public IStorageTranslator getStorageTranslator(String prefixPath) { return paths.get(prefixPath); } @Override
public IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/storage/Storage.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // }
import java.io.IOException; import java.util.HashMap; import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey;
package com.spedge.hangar.storage; public abstract class Storage implements IStorage { protected final Logger logger = LoggerFactory.getLogger(Storage.class); private HashMap<String, IStorageTranslator> paths = new HashMap<String, IStorageTranslator>(); @NotEmpty private String path; @JsonProperty public String getPath() { return path; } @JsonProperty public void setPath(String path) throws IOException { this.path = path; } protected void addPathTranslator(IStorageTranslator st, String path) { paths.put(path, st); } public IStorageTranslator getStorageTranslator(String prefixPath) { return paths.get(prefixPath); } @Override
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexArtifact.java // public abstract class IndexArtifact implements Serializable // { // private static final long serialVersionUID = -5720959937441417671L; // private String location; // // public IndexArtifact(String location) // { // this.location = location; // } // // public String getLocation() // { // return this.location; // } // // /** // * Checks if this type of file (on postfix) // * has been stored in the storage layer. // * // * @param filename Full filename to check // * @return True if file has been stored // */ // public boolean isStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // return getFileTypes().get(key); // } // } // return false; // } // // /** // * Sets that this particular type of file has been stored // * within the storage layer for later reference. // * // * @param filename Full filename to check // */ // public void setStoredFile(String filename) // { // for (String key : getFileTypes().keySet()) // { // if (filename.endsWith(key)) // { // getFileTypes().put(key, true); // } // } // } // // protected abstract Map<String, Boolean> getFileTypes(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexException.java // public class IndexException extends Exception // { // private static final long serialVersionUID = 6617225189161552873L; // // public IndexException(Exception ie) // { // super(ie); // } // // public IndexException(String message) // { // super(message); // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/storage/Storage.java import java.io.IOException; import java.util.HashMap; import org.hibernate.validator.constraints.NotEmpty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IndexArtifact; import com.spedge.hangar.index.IndexException; import com.spedge.hangar.index.IndexKey; package com.spedge.hangar.storage; public abstract class Storage implements IStorage { protected final Logger logger = LoggerFactory.getLogger(Storage.class); private HashMap<String, IStorageTranslator> paths = new HashMap<String, IStorageTranslator>(); @NotEmpty private String path; @JsonProperty public String getPath() { return path; } @JsonProperty public void setPath(String path) throws IOException { this.path = path; } protected void addPathTranslator(IStorageTranslator st, String path) { paths.put(path, st); } public IStorageTranslator getStorageTranslator(String prefixPath) { return paths.get(prefixPath); } @Override
public IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/repo/python/PythonIndexKey.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // }
import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType;
package com.spedge.hangar.repo.python; public class PythonIndexKey extends IndexKey { private String artifact; private String filename; /** * Saves the main details for identifying a package within Pip. * @param type RepositoryType this index item is from * @param artifact Name of the artifact * @param filename Name of the actual file being served */
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexKey.java // public class IndexKey // { // private String key; // private RepositoryType type = RepositoryType.UNKNOWN; // // public IndexKey(RepositoryType type, String key) // { // this.key = key; // this.type = type; // } // // public RepositoryType getType() // { // return type; // } // // public String toPath() // { // return key; // } // // public String toString() // { // return type.getLanguage() + ":" + key; // } // // /* (non-Javadoc) // * @see java.lang.Object#hashCode() // */ // @Override // public int hashCode() // { // final int prime = 31; // int result = 1; // result = prime * result + ((key == null) ? 0 : key.hashCode()); // result = prime * result + ((type.getLanguage() == null) ? 0 : type.getLanguage().hashCode()); // return result; // } // // /* (non-Javadoc) // * @see java.lang.Object#equals(java.lang.Object) // */ // @Override // public boolean equals(Object obj) // { // if (this == obj) // { // return true; // } // if (obj == null) // { // return false; // } // if (getClass() != obj.getClass()) // { // return false; // } // IndexKey other = (IndexKey) obj; // if (key == null) // { // if (other.key != null) // { // return false; // } // } // else if (!key.equals(other.key)) // { // return false; // } // if (type.getLanguage() != other.type.getLanguage()) // { // return false; // } // return true; // } // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/RepositoryType.java // public enum RepositoryType // { // RELEASE_JAVA(RepositoryLanguage.JAVA), // SNAPSHOT_JAVA(RepositoryLanguage.JAVA), // PROXY_JAVA(RepositoryLanguage.JAVA), // PROXY_PYTHON(RepositoryLanguage.PYTHON), // UNKNOWN(RepositoryLanguage.UNKNOWN); // // private RepositoryLanguage lang; // // RepositoryType(RepositoryLanguage lang) // { // this.lang = lang; // } // // public RepositoryLanguage getLanguage() // { // return lang; // } // } // Path: hangar-api/src/main/java/com/spedge/hangar/repo/python/PythonIndexKey.java import com.spedge.hangar.index.IndexKey; import com.spedge.hangar.repo.RepositoryType; package com.spedge.hangar.repo.python; public class PythonIndexKey extends IndexKey { private String artifact; private String filename; /** * Saves the main details for identifying a package within Pip. * @param type RepositoryType this index item is from * @param artifact Name of the artifact * @param filename Name of the actual file being served */
public PythonIndexKey(RepositoryType type, String artifact, String filename)
Spedge/hangar
hangar-api/src/test/java/com/spedge/hangar/index/zookeeper/TestZookeeperIndex.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // }
import static org.junit.Assert.assertEquals; import org.apache.curator.test.TestingServer; import org.apache.curator.utils.CloseableUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.testutils.IndexUtils;
package com.spedge.hangar.index.zookeeper; public class TestZookeeperIndex { ZooKeeperIndex index; @Before public void setupIndex() throws Exception { index = new ZooKeeperIndex(); } @Test public void testAddArtifact() throws Exception { TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add an artifact.
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // } // Path: hangar-api/src/test/java/com/spedge/hangar/index/zookeeper/TestZookeeperIndex.java import static org.junit.Assert.assertEquals; import org.apache.curator.test.TestingServer; import org.apache.curator.utils.CloseableUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.testutils.IndexUtils; package com.spedge.hangar.index.zookeeper; public class TestZookeeperIndex { ZooKeeperIndex index; @Before public void setupIndex() throws Exception { index = new ZooKeeperIndex(); } @Test public void testAddArtifact() throws Exception { TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add an artifact.
index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact());
Spedge/hangar
hangar-api/src/test/java/com/spedge/hangar/index/zookeeper/TestZookeeperIndex.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // }
import static org.junit.Assert.assertEquals; import org.apache.curator.test.TestingServer; import org.apache.curator.utils.CloseableUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.testutils.IndexUtils;
TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add an artifact. index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); // Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } finally { CloseableUtils.closeQuietly(testingServer); } } @Test public void testReservedArtifact() throws Exception { TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add a reserved artifact
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // } // Path: hangar-api/src/test/java/com/spedge/hangar/index/zookeeper/TestZookeeperIndex.java import static org.junit.Assert.assertEquals; import org.apache.curator.test.TestingServer; import org.apache.curator.utils.CloseableUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.testutils.IndexUtils; TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add an artifact. index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); // Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } finally { CloseableUtils.closeQuietly(testingServer); } } @Test public void testReservedArtifact() throws Exception { TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add a reserved artifact
ReservedArtifact ra = index.addReservationKey(IndexUtils.TEST2.getKey());
Spedge/hangar
hangar-api/src/test/java/com/spedge/hangar/index/zookeeper/TestZookeeperIndex.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // }
import static org.junit.Assert.assertEquals; import org.apache.curator.test.TestingServer; import org.apache.curator.utils.CloseableUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.testutils.IndexUtils;
// Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } finally { CloseableUtils.closeQuietly(testingServer); } } @Test public void testReservedArtifact() throws Exception { TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add a reserved artifact ReservedArtifact ra = index.addReservationKey(IndexUtils.TEST2.getKey()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST2.getKey())); try { index.addArtifact(IndexUtils.TEST2.getKey(), IndexUtils.TEST2.getArtifact()); Assert.fail("Index Conflict was never triggered."); }
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java // public class IndexConfictException extends Exception // { // // private static final long serialVersionUID = -4856615780463752787L; // // } // // Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java // public class ReservedArtifact extends IndexArtifact // { // private static final long serialVersionUID = -5676826253822808582L; // private final UUID id; // private Map<String, Boolean> files = new HashMap<String, Boolean>(); // // public ReservedArtifact(String location) // { // super(location); // id = UUID.randomUUID(); // } // // @Override // protected Map<String, Boolean> getFileTypes() // { // return files; // } // // public UUID getId() // { // return id; // } // // @Override // public boolean equals(Object object) // { // // self check // if (this == object) // { // return true; // } // // null check // if (object == null) // { // return false; // } // // type check and cast // if (getClass() != object.getClass()) // { // return false; // } // // ReservedArtifact ra = (ReservedArtifact) object; // // return Objects.equals(getLocation(), ra.getLocation()) // && Objects.equals(getId(), ra.getId()) // && Objects.equals(getFileTypes(), ra.getFileTypes()); // } // } // // Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java // public enum IndexUtils // { // TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"), // generateArtifact("/this/is/a/location/")), // TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"), // generateArtifact("/this/is/another/location/")); // // private IndexKey key; // private IndexArtifact ia; // // IndexUtils(IndexKey key, IndexArtifact artifact) // { // this.key = key; // this.ia = artifact; // } // // public IndexKey getKey() { // return this.key; // } // // public IndexArtifact getArtifact() { // return this.ia; // } // // private static IndexArtifact generateArtifact(String location) // { // IndexArtifact ia = new JavaIndexArtifact(location); // return ia; // } // } // Path: hangar-api/src/test/java/com/spedge/hangar/index/zookeeper/TestZookeeperIndex.java import static org.junit.Assert.assertEquals; import org.apache.curator.test.TestingServer; import org.apache.curator.utils.CloseableUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.spedge.hangar.index.IndexConfictException; import com.spedge.hangar.index.ReservedArtifact; import com.spedge.hangar.testutils.IndexUtils; // Get the artifact. assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); } finally { CloseableUtils.closeQuietly(testingServer); } } @Test public void testReservedArtifact() throws Exception { TestingServer testingServer = new TestingServer(); index.startClient(testingServer.getConnectString()); try { // Add a reserved artifact ReservedArtifact ra = index.addReservationKey(IndexUtils.TEST2.getKey()); // Is there an artifact? Assert.assertTrue(index.isArtifact(IndexUtils.TEST2.getKey())); try { index.addArtifact(IndexUtils.TEST2.getKey(), IndexUtils.TEST2.getArtifact()); Assert.fail("Index Conflict was never triggered."); }
catch(IndexConfictException ice){}
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IIndex.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "index") // @JsonSubTypes( // { // @JsonSubTypes.Type(value = InMemoryIndex.class, name = "in-memory"), // @JsonSubTypes.Type(value = ZooKeeperIndex.class, name = "zookeeper"), // }) // public interface IIndex // { // // /** // * Confirms that this particular artifact is registered // * @param key IndexKey for Artifact // * @return True is Artifact is registered // * @throws IndexException If this check cannot be performed. // */ // boolean isArtifact(IndexKey key) throws IndexException; // // /** // * Add an Artifact to the Index. // * @param key IndexKey for Artifact // * @param artifact Artifact to be registered with Index // * @throws IndexConfictException If this artifact exists and can't be overwritten // * @throws IndexException If this artifact cannot be registered for another reason // */ // void addArtifact(IndexKey key, IndexArtifact artifact) // throws IndexConfictException, IndexException; // // // Once we're happy with the artifact we want to get, // // we need details of where to stream it from. // IndexArtifact getArtifact(IndexKey key) throws IndexException; // // // When the index is empty on startup, we load it // // from the appropriate storage. // void load(RepositoryType type, IStorage storage, String uploadPath) // throws StorageException, IndexException; // // // This allows a upload to reserve a path before uploading to it. // ReservedArtifact addReservationKey(IndexKey key) throws IndexException; // // // This allows the update to the reservation to the completed location. // void addReservedArtifact(IndexKey key, ReservedArtifact reservation, IndexArtifact ia) // throws IndexConfictException, IndexException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorage.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "store") // @JsonSubTypes( // { @JsonSubTypes.Type(value = LocalStorage.class, name = "local"), // @JsonSubTypes.Type(value = S3Storage.class, name = "s3"), // }) // public interface IStorage // { // void initialiseStorage(IStorageTranslator st, String uploadPath) throws StorageException; // // HealthCheck getHealthcheck(); // // IStorageTranslator getStorageTranslator(String prefixPath); // // List<IndexKey> getArtifactKeys(String uploadPath) throws StorageException; // // StreamingOutput getArtifactStream(IndexArtifact key, String filename); // // IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // void uploadReleaseArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // void uploadSnapshotArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // String getPath(); // }
import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IIndex; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.storage.IStorage; import io.dropwizard.Configuration; import org.hibernate.validator.constraints.NotEmpty; import java.util.List;
package com.spedge.hangar.config; public class HangarConfiguration extends Configuration { @JsonProperty
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IIndex.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "index") // @JsonSubTypes( // { // @JsonSubTypes.Type(value = InMemoryIndex.class, name = "in-memory"), // @JsonSubTypes.Type(value = ZooKeeperIndex.class, name = "zookeeper"), // }) // public interface IIndex // { // // /** // * Confirms that this particular artifact is registered // * @param key IndexKey for Artifact // * @return True is Artifact is registered // * @throws IndexException If this check cannot be performed. // */ // boolean isArtifact(IndexKey key) throws IndexException; // // /** // * Add an Artifact to the Index. // * @param key IndexKey for Artifact // * @param artifact Artifact to be registered with Index // * @throws IndexConfictException If this artifact exists and can't be overwritten // * @throws IndexException If this artifact cannot be registered for another reason // */ // void addArtifact(IndexKey key, IndexArtifact artifact) // throws IndexConfictException, IndexException; // // // Once we're happy with the artifact we want to get, // // we need details of where to stream it from. // IndexArtifact getArtifact(IndexKey key) throws IndexException; // // // When the index is empty on startup, we load it // // from the appropriate storage. // void load(RepositoryType type, IStorage storage, String uploadPath) // throws StorageException, IndexException; // // // This allows a upload to reserve a path before uploading to it. // ReservedArtifact addReservationKey(IndexKey key) throws IndexException; // // // This allows the update to the reservation to the completed location. // void addReservedArtifact(IndexKey key, ReservedArtifact reservation, IndexArtifact ia) // throws IndexConfictException, IndexException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorage.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "store") // @JsonSubTypes( // { @JsonSubTypes.Type(value = LocalStorage.class, name = "local"), // @JsonSubTypes.Type(value = S3Storage.class, name = "s3"), // }) // public interface IStorage // { // void initialiseStorage(IStorageTranslator st, String uploadPath) throws StorageException; // // HealthCheck getHealthcheck(); // // IStorageTranslator getStorageTranslator(String prefixPath); // // List<IndexKey> getArtifactKeys(String uploadPath) throws StorageException; // // StreamingOutput getArtifactStream(IndexArtifact key, String filename); // // IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // void uploadReleaseArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // void uploadSnapshotArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // String getPath(); // } // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IIndex; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.storage.IStorage; import io.dropwizard.Configuration; import org.hibernate.validator.constraints.NotEmpty; import java.util.List; package com.spedge.hangar.config; public class HangarConfiguration extends Configuration { @JsonProperty
private IStorage storage;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IIndex.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "index") // @JsonSubTypes( // { // @JsonSubTypes.Type(value = InMemoryIndex.class, name = "in-memory"), // @JsonSubTypes.Type(value = ZooKeeperIndex.class, name = "zookeeper"), // }) // public interface IIndex // { // // /** // * Confirms that this particular artifact is registered // * @param key IndexKey for Artifact // * @return True is Artifact is registered // * @throws IndexException If this check cannot be performed. // */ // boolean isArtifact(IndexKey key) throws IndexException; // // /** // * Add an Artifact to the Index. // * @param key IndexKey for Artifact // * @param artifact Artifact to be registered with Index // * @throws IndexConfictException If this artifact exists and can't be overwritten // * @throws IndexException If this artifact cannot be registered for another reason // */ // void addArtifact(IndexKey key, IndexArtifact artifact) // throws IndexConfictException, IndexException; // // // Once we're happy with the artifact we want to get, // // we need details of where to stream it from. // IndexArtifact getArtifact(IndexKey key) throws IndexException; // // // When the index is empty on startup, we load it // // from the appropriate storage. // void load(RepositoryType type, IStorage storage, String uploadPath) // throws StorageException, IndexException; // // // This allows a upload to reserve a path before uploading to it. // ReservedArtifact addReservationKey(IndexKey key) throws IndexException; // // // This allows the update to the reservation to the completed location. // void addReservedArtifact(IndexKey key, ReservedArtifact reservation, IndexArtifact ia) // throws IndexConfictException, IndexException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorage.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "store") // @JsonSubTypes( // { @JsonSubTypes.Type(value = LocalStorage.class, name = "local"), // @JsonSubTypes.Type(value = S3Storage.class, name = "s3"), // }) // public interface IStorage // { // void initialiseStorage(IStorageTranslator st, String uploadPath) throws StorageException; // // HealthCheck getHealthcheck(); // // IStorageTranslator getStorageTranslator(String prefixPath); // // List<IndexKey> getArtifactKeys(String uploadPath) throws StorageException; // // StreamingOutput getArtifactStream(IndexArtifact key, String filename); // // IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // void uploadReleaseArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // void uploadSnapshotArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // String getPath(); // }
import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IIndex; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.storage.IStorage; import io.dropwizard.Configuration; import org.hibernate.validator.constraints.NotEmpty; import java.util.List;
package com.spedge.hangar.config; public class HangarConfiguration extends Configuration { @JsonProperty private IStorage storage; @JsonProperty
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IIndex.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "index") // @JsonSubTypes( // { // @JsonSubTypes.Type(value = InMemoryIndex.class, name = "in-memory"), // @JsonSubTypes.Type(value = ZooKeeperIndex.class, name = "zookeeper"), // }) // public interface IIndex // { // // /** // * Confirms that this particular artifact is registered // * @param key IndexKey for Artifact // * @return True is Artifact is registered // * @throws IndexException If this check cannot be performed. // */ // boolean isArtifact(IndexKey key) throws IndexException; // // /** // * Add an Artifact to the Index. // * @param key IndexKey for Artifact // * @param artifact Artifact to be registered with Index // * @throws IndexConfictException If this artifact exists and can't be overwritten // * @throws IndexException If this artifact cannot be registered for another reason // */ // void addArtifact(IndexKey key, IndexArtifact artifact) // throws IndexConfictException, IndexException; // // // Once we're happy with the artifact we want to get, // // we need details of where to stream it from. // IndexArtifact getArtifact(IndexKey key) throws IndexException; // // // When the index is empty on startup, we load it // // from the appropriate storage. // void load(RepositoryType type, IStorage storage, String uploadPath) // throws StorageException, IndexException; // // // This allows a upload to reserve a path before uploading to it. // ReservedArtifact addReservationKey(IndexKey key) throws IndexException; // // // This allows the update to the reservation to the completed location. // void addReservedArtifact(IndexKey key, ReservedArtifact reservation, IndexArtifact ia) // throws IndexConfictException, IndexException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorage.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "store") // @JsonSubTypes( // { @JsonSubTypes.Type(value = LocalStorage.class, name = "local"), // @JsonSubTypes.Type(value = S3Storage.class, name = "s3"), // }) // public interface IStorage // { // void initialiseStorage(IStorageTranslator st, String uploadPath) throws StorageException; // // HealthCheck getHealthcheck(); // // IStorageTranslator getStorageTranslator(String prefixPath); // // List<IndexKey> getArtifactKeys(String uploadPath) throws StorageException; // // StreamingOutput getArtifactStream(IndexArtifact key, String filename); // // IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // void uploadReleaseArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // void uploadSnapshotArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // String getPath(); // } // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IIndex; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.storage.IStorage; import io.dropwizard.Configuration; import org.hibernate.validator.constraints.NotEmpty; import java.util.List; package com.spedge.hangar.config; public class HangarConfiguration extends Configuration { @JsonProperty private IStorage storage; @JsonProperty
private IIndex artifactIndex;
Spedge/hangar
hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IIndex.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "index") // @JsonSubTypes( // { // @JsonSubTypes.Type(value = InMemoryIndex.class, name = "in-memory"), // @JsonSubTypes.Type(value = ZooKeeperIndex.class, name = "zookeeper"), // }) // public interface IIndex // { // // /** // * Confirms that this particular artifact is registered // * @param key IndexKey for Artifact // * @return True is Artifact is registered // * @throws IndexException If this check cannot be performed. // */ // boolean isArtifact(IndexKey key) throws IndexException; // // /** // * Add an Artifact to the Index. // * @param key IndexKey for Artifact // * @param artifact Artifact to be registered with Index // * @throws IndexConfictException If this artifact exists and can't be overwritten // * @throws IndexException If this artifact cannot be registered for another reason // */ // void addArtifact(IndexKey key, IndexArtifact artifact) // throws IndexConfictException, IndexException; // // // Once we're happy with the artifact we want to get, // // we need details of where to stream it from. // IndexArtifact getArtifact(IndexKey key) throws IndexException; // // // When the index is empty on startup, we load it // // from the appropriate storage. // void load(RepositoryType type, IStorage storage, String uploadPath) // throws StorageException, IndexException; // // // This allows a upload to reserve a path before uploading to it. // ReservedArtifact addReservationKey(IndexKey key) throws IndexException; // // // This allows the update to the reservation to the completed location. // void addReservedArtifact(IndexKey key, ReservedArtifact reservation, IndexArtifact ia) // throws IndexConfictException, IndexException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorage.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "store") // @JsonSubTypes( // { @JsonSubTypes.Type(value = LocalStorage.class, name = "local"), // @JsonSubTypes.Type(value = S3Storage.class, name = "s3"), // }) // public interface IStorage // { // void initialiseStorage(IStorageTranslator st, String uploadPath) throws StorageException; // // HealthCheck getHealthcheck(); // // IStorageTranslator getStorageTranslator(String prefixPath); // // List<IndexKey> getArtifactKeys(String uploadPath) throws StorageException; // // StreamingOutput getArtifactStream(IndexArtifact key, String filename); // // IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // void uploadReleaseArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // void uploadSnapshotArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // String getPath(); // }
import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IIndex; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.storage.IStorage; import io.dropwizard.Configuration; import org.hibernate.validator.constraints.NotEmpty; import java.util.List;
package com.spedge.hangar.config; public class HangarConfiguration extends Configuration { @JsonProperty private IStorage storage; @JsonProperty private IIndex artifactIndex; @NotEmpty @JsonProperty
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IIndex.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "index") // @JsonSubTypes( // { // @JsonSubTypes.Type(value = InMemoryIndex.class, name = "in-memory"), // @JsonSubTypes.Type(value = ZooKeeperIndex.class, name = "zookeeper"), // }) // public interface IIndex // { // // /** // * Confirms that this particular artifact is registered // * @param key IndexKey for Artifact // * @return True is Artifact is registered // * @throws IndexException If this check cannot be performed. // */ // boolean isArtifact(IndexKey key) throws IndexException; // // /** // * Add an Artifact to the Index. // * @param key IndexKey for Artifact // * @param artifact Artifact to be registered with Index // * @throws IndexConfictException If this artifact exists and can't be overwritten // * @throws IndexException If this artifact cannot be registered for another reason // */ // void addArtifact(IndexKey key, IndexArtifact artifact) // throws IndexConfictException, IndexException; // // // Once we're happy with the artifact we want to get, // // we need details of where to stream it from. // IndexArtifact getArtifact(IndexKey key) throws IndexException; // // // When the index is empty on startup, we load it // // from the appropriate storage. // void load(RepositoryType type, IStorage storage, String uploadPath) // throws StorageException, IndexException; // // // This allows a upload to reserve a path before uploading to it. // ReservedArtifact addReservationKey(IndexKey key) throws IndexException; // // // This allows the update to the reservation to the completed location. // void addReservedArtifact(IndexKey key, ReservedArtifact reservation, IndexArtifact ia) // throws IndexConfictException, IndexException; // } // // Path: hangar-api/src/main/java/com/spedge/hangar/repo/IRepository.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") // @JsonSubTypes( // { @JsonSubTypes.Type(value = JavaDownloadEndpoint.class, name = "java-download"), // @JsonSubTypes.Type(value = JavaReleaseEndpoint.class, name = "java-release"), // @JsonSubTypes.Type(value = JavaSnapshotEndpoint.class, name = "java-snapshot"), // @JsonSubTypes.Type(value = PythonDownloadEndpoint.class, name = "python-download") // }) // public interface IRepository // { // // /** // * Each repository should provide custom healthchecks for it's own use // * cases. // * // * @return An map of healthchecks // */ // Map<String, HealthCheck> getHealthChecks(); // // /** // * After initial configuration, this command is run in order to set-up or // * load the repository and get it to a state where it's ready to run. // * // * @param configuration HangarConfiguration passed in as YAML // * @param environment Dropwizard environment // * @throws StorageException Thrown when Storage initialisation fails. // * @throws IndexException Thrown when Index initialisation fails. // */ // void loadRepository(HangarConfiguration configuration, Environment environment) // throws StorageException, IndexException; // // /** // * Retrieves the storage configured for the repositories (One storage for all // * repos). // * // * @return Returns the storage for this repository // */ // IStorage getStorage(); // // /** // * Returns the index configured for the repositories (One index for all // * repos). // * // * @return Returns the index for this repository // */ // IIndex getIndex(); // } // // Path: hangar-api/src/main/java/com/spedge/hangar/storage/IStorage.java // @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "store") // @JsonSubTypes( // { @JsonSubTypes.Type(value = LocalStorage.class, name = "local"), // @JsonSubTypes.Type(value = S3Storage.class, name = "s3"), // }) // public interface IStorage // { // void initialiseStorage(IStorageTranslator st, String uploadPath) throws StorageException; // // HealthCheck getHealthcheck(); // // IStorageTranslator getStorageTranslator(String prefixPath); // // List<IndexKey> getArtifactKeys(String uploadPath) throws StorageException; // // StreamingOutput getArtifactStream(IndexArtifact key, String filename); // // IndexArtifact getIndexArtifact(IndexKey key, String uploadPath) throws IndexException; // // void uploadReleaseArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // void uploadSnapshotArtifactStream(IndexArtifact ia, StorageRequest sr) throws StorageException; // // String getPath(); // } // Path: hangar-api/src/main/java/com/spedge/hangar/config/HangarConfiguration.java import com.fasterxml.jackson.annotation.JsonProperty; import com.spedge.hangar.index.IIndex; import com.spedge.hangar.repo.IRepository; import com.spedge.hangar.storage.IStorage; import io.dropwizard.Configuration; import org.hibernate.validator.constraints.NotEmpty; import java.util.List; package com.spedge.hangar.config; public class HangarConfiguration extends Configuration { @JsonProperty private IStorage storage; @JsonProperty private IIndex artifactIndex; @NotEmpty @JsonProperty
private List<IRepository> repositories;
henrysher/bootchart
src/org/bootchart/parser/linux/ProcPsParser.java
// Path: src/org/bootchart/common/CPUSample.java // public class CPUSample extends Sample { // /** User load. */ // public double user; // /** System load. */ // public double sys; // /** The percentage of CPU time spent waiting on disk I/O. */ // public double io; // // /** // * Creates a new sample. // * // * @param time sample time // * @param user user load // * @param sys system load // * @param io IO wait // */ // public CPUSample(Date time, double user, double sys, double io) { // this.time = time != null ? new Date(time.getTime()) : null; // this.user = user; // this.sys = sys; // this.io = io; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // String t = time != null ? time.getTime() + "\t" : ""; // return t + user + "\t" + sys + "\t" + io; // } // } // // Path: src/org/bootchart/common/ProcessSample.java // public class ProcessSample extends Sample { // /** Process state. */ // public int state; // /** CPU statistics. */ // public CPUSample cpu; // /** Disk utlization statistics. */ // public DiskUtilSample diskUtil; // /** Disk troughput statistics. */ // public DiskTPutSample diskTPut; // // /** // * Creates a new process sample. // * // * @param time sample time // * @param state proces state // * @param cpu CPU sample // * @param diskUtil disk utilization sample // * @param diskTPut disk throughput sample // */ // public ProcessSample(Date time, int state, CPUSample cpu, // DiskUtilSample diskUtil, DiskTPutSample diskTPut) { // this.time = time != null ? new Date(time.getTime()) : null; // this.state = state; // this.cpu = cpu; // this.diskUtil = diskUtil; // this.diskTPut = diskTPut; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return time.getTime() + "\t" + state + "\t" + cpu + "\t" + diskUtil + "\t" + diskTPut; // } // } // // Path: src/org/bootchart/common/PsStats.java // public class PsStats { // /** A list of processes (with enclosing CPU samples). */ // public List processList; // /** Statistics sampling period. */ // public int samplePeriod; // /** Start and end of sampling period. */ // public Date startTime; // public Date endTime; // }
import org.bootchart.common.CPUSample; import org.bootchart.common.Common; import org.bootchart.common.Process; import org.bootchart.common.ProcessSample; import org.bootchart.common.PsStats; import org.bootchart.common.Sample; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Logger;
/* * Bootchart -- Boot Process Visualization * * Copyright (C) 2004 Ziga Mahkovec <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.bootchart.parser.linux; /** * ProcPsParser parses log files produced by logging the output of * <code>/proc/[PID]/stat</code> files. The samples contain status * information about processes (PID, command, state, PPID, user and system * CPU times, etc.). */ public class ProcPsParser { private static final Logger log = Logger.getLogger(ProcPsParser.class.getName()); /** * Maximum time difference between two consecutive samples. Anything more * indicates an error. */ private static final int MAX_SAMPLE_DIFF = 60000; /** * Maximum uptime for a sample. Used to sanity check log file values and * ignore inconsistent samples. */ private static final long MAX_UPTIME = System.currentTimeMillis() - 1072911600000L; // 30 years+ uptime /** * Parses the <code>proc_ps.log</code> file. The output from * <code>/proc/[PID]stat</code> is used to collect process * information. * * <p>If <code>pidNameMap</code> is set, it is used to map PIDs to * command names. This is useful when init scripts are sourced, and thus * ps is unable to report the proper process name. A sysinit * modification is necessary to generate the mapping log file.</p> * <p><code>forkMap</code> is an optional map that provides detailed * information about process forking.<p> * * @param is the input stream to read from * @param pidNameMap PID to name mapping map (optional) * @param forkMap process forking map (optional) * @return process statistics * @throws IOException if an I/O error occurs */
// Path: src/org/bootchart/common/CPUSample.java // public class CPUSample extends Sample { // /** User load. */ // public double user; // /** System load. */ // public double sys; // /** The percentage of CPU time spent waiting on disk I/O. */ // public double io; // // /** // * Creates a new sample. // * // * @param time sample time // * @param user user load // * @param sys system load // * @param io IO wait // */ // public CPUSample(Date time, double user, double sys, double io) { // this.time = time != null ? new Date(time.getTime()) : null; // this.user = user; // this.sys = sys; // this.io = io; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // String t = time != null ? time.getTime() + "\t" : ""; // return t + user + "\t" + sys + "\t" + io; // } // } // // Path: src/org/bootchart/common/ProcessSample.java // public class ProcessSample extends Sample { // /** Process state. */ // public int state; // /** CPU statistics. */ // public CPUSample cpu; // /** Disk utlization statistics. */ // public DiskUtilSample diskUtil; // /** Disk troughput statistics. */ // public DiskTPutSample diskTPut; // // /** // * Creates a new process sample. // * // * @param time sample time // * @param state proces state // * @param cpu CPU sample // * @param diskUtil disk utilization sample // * @param diskTPut disk throughput sample // */ // public ProcessSample(Date time, int state, CPUSample cpu, // DiskUtilSample diskUtil, DiskTPutSample diskTPut) { // this.time = time != null ? new Date(time.getTime()) : null; // this.state = state; // this.cpu = cpu; // this.diskUtil = diskUtil; // this.diskTPut = diskTPut; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return time.getTime() + "\t" + state + "\t" + cpu + "\t" + diskUtil + "\t" + diskTPut; // } // } // // Path: src/org/bootchart/common/PsStats.java // public class PsStats { // /** A list of processes (with enclosing CPU samples). */ // public List processList; // /** Statistics sampling period. */ // public int samplePeriod; // /** Start and end of sampling period. */ // public Date startTime; // public Date endTime; // } // Path: src/org/bootchart/parser/linux/ProcPsParser.java import org.bootchart.common.CPUSample; import org.bootchart.common.Common; import org.bootchart.common.Process; import org.bootchart.common.ProcessSample; import org.bootchart.common.PsStats; import org.bootchart.common.Sample; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Logger; /* * Bootchart -- Boot Process Visualization * * Copyright (C) 2004 Ziga Mahkovec <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.bootchart.parser.linux; /** * ProcPsParser parses log files produced by logging the output of * <code>/proc/[PID]/stat</code> files. The samples contain status * information about processes (PID, command, state, PPID, user and system * CPU times, etc.). */ public class ProcPsParser { private static final Logger log = Logger.getLogger(ProcPsParser.class.getName()); /** * Maximum time difference between two consecutive samples. Anything more * indicates an error. */ private static final int MAX_SAMPLE_DIFF = 60000; /** * Maximum uptime for a sample. Used to sanity check log file values and * ignore inconsistent samples. */ private static final long MAX_UPTIME = System.currentTimeMillis() - 1072911600000L; // 30 years+ uptime /** * Parses the <code>proc_ps.log</code> file. The output from * <code>/proc/[PID]stat</code> is used to collect process * information. * * <p>If <code>pidNameMap</code> is set, it is used to map PIDs to * command names. This is useful when init scripts are sourced, and thus * ps is unable to report the proper process name. A sysinit * modification is necessary to generate the mapping log file.</p> * <p><code>forkMap</code> is an optional map that provides detailed * information about process forking.<p> * * @param is the input stream to read from * @param pidNameMap PID to name mapping map (optional) * @param forkMap process forking map (optional) * @return process statistics * @throws IOException if an I/O error occurs */
public static PsStats parseLog(InputStream is, Map pidNameMap, Map forkMap)
henrysher/bootchart
src/org/bootchart/parser/linux/ProcPsParser.java
// Path: src/org/bootchart/common/CPUSample.java // public class CPUSample extends Sample { // /** User load. */ // public double user; // /** System load. */ // public double sys; // /** The percentage of CPU time spent waiting on disk I/O. */ // public double io; // // /** // * Creates a new sample. // * // * @param time sample time // * @param user user load // * @param sys system load // * @param io IO wait // */ // public CPUSample(Date time, double user, double sys, double io) { // this.time = time != null ? new Date(time.getTime()) : null; // this.user = user; // this.sys = sys; // this.io = io; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // String t = time != null ? time.getTime() + "\t" : ""; // return t + user + "\t" + sys + "\t" + io; // } // } // // Path: src/org/bootchart/common/ProcessSample.java // public class ProcessSample extends Sample { // /** Process state. */ // public int state; // /** CPU statistics. */ // public CPUSample cpu; // /** Disk utlization statistics. */ // public DiskUtilSample diskUtil; // /** Disk troughput statistics. */ // public DiskTPutSample diskTPut; // // /** // * Creates a new process sample. // * // * @param time sample time // * @param state proces state // * @param cpu CPU sample // * @param diskUtil disk utilization sample // * @param diskTPut disk throughput sample // */ // public ProcessSample(Date time, int state, CPUSample cpu, // DiskUtilSample diskUtil, DiskTPutSample diskTPut) { // this.time = time != null ? new Date(time.getTime()) : null; // this.state = state; // this.cpu = cpu; // this.diskUtil = diskUtil; // this.diskTPut = diskTPut; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return time.getTime() + "\t" + state + "\t" + cpu + "\t" + diskUtil + "\t" + diskTPut; // } // } // // Path: src/org/bootchart/common/PsStats.java // public class PsStats { // /** A list of processes (with enclosing CPU samples). */ // public List processList; // /** Statistics sampling period. */ // public int samplePeriod; // /** Start and end of sampling period. */ // public Date startTime; // public Date endTime; // }
import org.bootchart.common.CPUSample; import org.bootchart.common.Common; import org.bootchart.common.Process; import org.bootchart.common.ProcessSample; import org.bootchart.common.PsStats; import org.bootchart.common.Sample; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Logger;
Process proc = (Process)processMap.get(new Integer(pid)); if (proc == null) { int ppid = Integer.parseInt(data[1]); proc = new Process(pid, cmd); proc.ppid = ppid; proc.startTime = new Date(Math.min(Integer.parseInt(data[19]) * 10, time.getTime())); processMap.put(new Integer(pid), proc); } else { proc.cmd = cmd; } int state = getState(data[0]); long userCpu = Long.parseLong(data[11]); long sysCpu = Long.parseLong(data[12]); double cpuLoad = 0.0; Long lUserCpu = (Long)lastUserCpuTimes.get(new Integer(pid)); Long lSysCpu = (Long)lastSysCpuTimes.get(new Integer(pid)); if (lUserCpu != null && lSysCpu != null && ltime != null) { long interval = time.getTime() - ltime.getTime(); //interval = Math.max(interval, 1); double userCpuLoad = (double)(userCpu - lUserCpu.longValue()) * 10.0 / interval; double sysCpuLoad = (double)(sysCpu - lSysCpu.longValue()) * 10.0 / interval; cpuLoad = userCpuLoad + sysCpuLoad; // normalize if (cpuLoad > 1.0) { userCpuLoad /= cpuLoad; sysCpuLoad /= cpuLoad; }
// Path: src/org/bootchart/common/CPUSample.java // public class CPUSample extends Sample { // /** User load. */ // public double user; // /** System load. */ // public double sys; // /** The percentage of CPU time spent waiting on disk I/O. */ // public double io; // // /** // * Creates a new sample. // * // * @param time sample time // * @param user user load // * @param sys system load // * @param io IO wait // */ // public CPUSample(Date time, double user, double sys, double io) { // this.time = time != null ? new Date(time.getTime()) : null; // this.user = user; // this.sys = sys; // this.io = io; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // String t = time != null ? time.getTime() + "\t" : ""; // return t + user + "\t" + sys + "\t" + io; // } // } // // Path: src/org/bootchart/common/ProcessSample.java // public class ProcessSample extends Sample { // /** Process state. */ // public int state; // /** CPU statistics. */ // public CPUSample cpu; // /** Disk utlization statistics. */ // public DiskUtilSample diskUtil; // /** Disk troughput statistics. */ // public DiskTPutSample diskTPut; // // /** // * Creates a new process sample. // * // * @param time sample time // * @param state proces state // * @param cpu CPU sample // * @param diskUtil disk utilization sample // * @param diskTPut disk throughput sample // */ // public ProcessSample(Date time, int state, CPUSample cpu, // DiskUtilSample diskUtil, DiskTPutSample diskTPut) { // this.time = time != null ? new Date(time.getTime()) : null; // this.state = state; // this.cpu = cpu; // this.diskUtil = diskUtil; // this.diskTPut = diskTPut; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return time.getTime() + "\t" + state + "\t" + cpu + "\t" + diskUtil + "\t" + diskTPut; // } // } // // Path: src/org/bootchart/common/PsStats.java // public class PsStats { // /** A list of processes (with enclosing CPU samples). */ // public List processList; // /** Statistics sampling period. */ // public int samplePeriod; // /** Start and end of sampling period. */ // public Date startTime; // public Date endTime; // } // Path: src/org/bootchart/parser/linux/ProcPsParser.java import org.bootchart.common.CPUSample; import org.bootchart.common.Common; import org.bootchart.common.Process; import org.bootchart.common.ProcessSample; import org.bootchart.common.PsStats; import org.bootchart.common.Sample; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Logger; Process proc = (Process)processMap.get(new Integer(pid)); if (proc == null) { int ppid = Integer.parseInt(data[1]); proc = new Process(pid, cmd); proc.ppid = ppid; proc.startTime = new Date(Math.min(Integer.parseInt(data[19]) * 10, time.getTime())); processMap.put(new Integer(pid), proc); } else { proc.cmd = cmd; } int state = getState(data[0]); long userCpu = Long.parseLong(data[11]); long sysCpu = Long.parseLong(data[12]); double cpuLoad = 0.0; Long lUserCpu = (Long)lastUserCpuTimes.get(new Integer(pid)); Long lSysCpu = (Long)lastSysCpuTimes.get(new Integer(pid)); if (lUserCpu != null && lSysCpu != null && ltime != null) { long interval = time.getTime() - ltime.getTime(); //interval = Math.max(interval, 1); double userCpuLoad = (double)(userCpu - lUserCpu.longValue()) * 10.0 / interval; double sysCpuLoad = (double)(sysCpu - lSysCpu.longValue()) * 10.0 / interval; cpuLoad = userCpuLoad + sysCpuLoad; // normalize if (cpuLoad > 1.0) { userCpuLoad /= cpuLoad; sysCpuLoad /= cpuLoad; }
CPUSample procCpuSample = new CPUSample(null, userCpuLoad, sysCpuLoad, 0.0);
henrysher/bootchart
src/org/bootchart/parser/linux/ProcPsParser.java
// Path: src/org/bootchart/common/CPUSample.java // public class CPUSample extends Sample { // /** User load. */ // public double user; // /** System load. */ // public double sys; // /** The percentage of CPU time spent waiting on disk I/O. */ // public double io; // // /** // * Creates a new sample. // * // * @param time sample time // * @param user user load // * @param sys system load // * @param io IO wait // */ // public CPUSample(Date time, double user, double sys, double io) { // this.time = time != null ? new Date(time.getTime()) : null; // this.user = user; // this.sys = sys; // this.io = io; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // String t = time != null ? time.getTime() + "\t" : ""; // return t + user + "\t" + sys + "\t" + io; // } // } // // Path: src/org/bootchart/common/ProcessSample.java // public class ProcessSample extends Sample { // /** Process state. */ // public int state; // /** CPU statistics. */ // public CPUSample cpu; // /** Disk utlization statistics. */ // public DiskUtilSample diskUtil; // /** Disk troughput statistics. */ // public DiskTPutSample diskTPut; // // /** // * Creates a new process sample. // * // * @param time sample time // * @param state proces state // * @param cpu CPU sample // * @param diskUtil disk utilization sample // * @param diskTPut disk throughput sample // */ // public ProcessSample(Date time, int state, CPUSample cpu, // DiskUtilSample diskUtil, DiskTPutSample diskTPut) { // this.time = time != null ? new Date(time.getTime()) : null; // this.state = state; // this.cpu = cpu; // this.diskUtil = diskUtil; // this.diskTPut = diskTPut; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return time.getTime() + "\t" + state + "\t" + cpu + "\t" + diskUtil + "\t" + diskTPut; // } // } // // Path: src/org/bootchart/common/PsStats.java // public class PsStats { // /** A list of processes (with enclosing CPU samples). */ // public List processList; // /** Statistics sampling period. */ // public int samplePeriod; // /** Start and end of sampling period. */ // public Date startTime; // public Date endTime; // }
import org.bootchart.common.CPUSample; import org.bootchart.common.Common; import org.bootchart.common.Process; import org.bootchart.common.ProcessSample; import org.bootchart.common.PsStats; import org.bootchart.common.Sample; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Logger;
if (proc == null) { int ppid = Integer.parseInt(data[1]); proc = new Process(pid, cmd); proc.ppid = ppid; proc.startTime = new Date(Math.min(Integer.parseInt(data[19]) * 10, time.getTime())); processMap.put(new Integer(pid), proc); } else { proc.cmd = cmd; } int state = getState(data[0]); long userCpu = Long.parseLong(data[11]); long sysCpu = Long.parseLong(data[12]); double cpuLoad = 0.0; Long lUserCpu = (Long)lastUserCpuTimes.get(new Integer(pid)); Long lSysCpu = (Long)lastSysCpuTimes.get(new Integer(pid)); if (lUserCpu != null && lSysCpu != null && ltime != null) { long interval = time.getTime() - ltime.getTime(); //interval = Math.max(interval, 1); double userCpuLoad = (double)(userCpu - lUserCpu.longValue()) * 10.0 / interval; double sysCpuLoad = (double)(sysCpu - lSysCpu.longValue()) * 10.0 / interval; cpuLoad = userCpuLoad + sysCpuLoad; // normalize if (cpuLoad > 1.0) { userCpuLoad /= cpuLoad; sysCpuLoad /= cpuLoad; } CPUSample procCpuSample = new CPUSample(null, userCpuLoad, sysCpuLoad, 0.0);
// Path: src/org/bootchart/common/CPUSample.java // public class CPUSample extends Sample { // /** User load. */ // public double user; // /** System load. */ // public double sys; // /** The percentage of CPU time spent waiting on disk I/O. */ // public double io; // // /** // * Creates a new sample. // * // * @param time sample time // * @param user user load // * @param sys system load // * @param io IO wait // */ // public CPUSample(Date time, double user, double sys, double io) { // this.time = time != null ? new Date(time.getTime()) : null; // this.user = user; // this.sys = sys; // this.io = io; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // String t = time != null ? time.getTime() + "\t" : ""; // return t + user + "\t" + sys + "\t" + io; // } // } // // Path: src/org/bootchart/common/ProcessSample.java // public class ProcessSample extends Sample { // /** Process state. */ // public int state; // /** CPU statistics. */ // public CPUSample cpu; // /** Disk utlization statistics. */ // public DiskUtilSample diskUtil; // /** Disk troughput statistics. */ // public DiskTPutSample diskTPut; // // /** // * Creates a new process sample. // * // * @param time sample time // * @param state proces state // * @param cpu CPU sample // * @param diskUtil disk utilization sample // * @param diskTPut disk throughput sample // */ // public ProcessSample(Date time, int state, CPUSample cpu, // DiskUtilSample diskUtil, DiskTPutSample diskTPut) { // this.time = time != null ? new Date(time.getTime()) : null; // this.state = state; // this.cpu = cpu; // this.diskUtil = diskUtil; // this.diskTPut = diskTPut; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return time.getTime() + "\t" + state + "\t" + cpu + "\t" + diskUtil + "\t" + diskTPut; // } // } // // Path: src/org/bootchart/common/PsStats.java // public class PsStats { // /** A list of processes (with enclosing CPU samples). */ // public List processList; // /** Statistics sampling period. */ // public int samplePeriod; // /** Start and end of sampling period. */ // public Date startTime; // public Date endTime; // } // Path: src/org/bootchart/parser/linux/ProcPsParser.java import org.bootchart.common.CPUSample; import org.bootchart.common.Common; import org.bootchart.common.Process; import org.bootchart.common.ProcessSample; import org.bootchart.common.PsStats; import org.bootchart.common.Sample; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Logger; if (proc == null) { int ppid = Integer.parseInt(data[1]); proc = new Process(pid, cmd); proc.ppid = ppid; proc.startTime = new Date(Math.min(Integer.parseInt(data[19]) * 10, time.getTime())); processMap.put(new Integer(pid), proc); } else { proc.cmd = cmd; } int state = getState(data[0]); long userCpu = Long.parseLong(data[11]); long sysCpu = Long.parseLong(data[12]); double cpuLoad = 0.0; Long lUserCpu = (Long)lastUserCpuTimes.get(new Integer(pid)); Long lSysCpu = (Long)lastSysCpuTimes.get(new Integer(pid)); if (lUserCpu != null && lSysCpu != null && ltime != null) { long interval = time.getTime() - ltime.getTime(); //interval = Math.max(interval, 1); double userCpuLoad = (double)(userCpu - lUserCpu.longValue()) * 10.0 / interval; double sysCpuLoad = (double)(sysCpu - lSysCpu.longValue()) * 10.0 / interval; cpuLoad = userCpuLoad + sysCpuLoad; // normalize if (cpuLoad > 1.0) { userCpuLoad /= cpuLoad; sysCpuLoad /= cpuLoad; } CPUSample procCpuSample = new CPUSample(null, userCpuLoad, sysCpuLoad, 0.0);
ProcessSample procSample =
henrysher/bootchart
src/org/bootchart/parser/linux/ProcDiskStatParser.java
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // }
import org.bootchart.common.DiskTPutSample; import org.bootchart.common.DiskUtilSample; import org.bootchart.common.Sample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common;
/* * Bootchart -- Boot Process Visualization * * Copyright (C) 2004 Ziga Mahkovec <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.bootchart.parser.linux; /** * ProcDiskStatParser parses log files produced by logging the output of * <code>/proc/diskstats</code>. The samples contain information about disk * IO activity. */ public class ProcDiskStatParser { private static final Logger log = Logger.getLogger(ProcDiskStatParser.class.getName()); private static final String DISK_REGEX = "hd.|sd."; /** DiskStatSample encapsulates a /proc/diskstat sample. */ private static class DiskStatSample { long[] values = new long[3]; // {rsect, wsect, use} long[] changes = new long[3]; // {rsect, wsect, use} } /** * Parses the <code>proc_diskstats.log</code> file. The output from * <code>/proc/diskstat</code> is used to collect the disk statistics. * * @param is the input stream to read from * @param numCpu number of processors * @return disk statistics ({@link DiskUtilSample} and * {@link DiskTPutSample} samples) * @throws IOException if an I/O error occurs */
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // } // Path: src/org/bootchart/parser/linux/ProcDiskStatParser.java import org.bootchart.common.DiskTPutSample; import org.bootchart.common.DiskUtilSample; import org.bootchart.common.Sample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common; /* * Bootchart -- Boot Process Visualization * * Copyright (C) 2004 Ziga Mahkovec <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.bootchart.parser.linux; /** * ProcDiskStatParser parses log files produced by logging the output of * <code>/proc/diskstats</code>. The samples contain information about disk * IO activity. */ public class ProcDiskStatParser { private static final Logger log = Logger.getLogger(ProcDiskStatParser.class.getName()); private static final String DISK_REGEX = "hd.|sd."; /** DiskStatSample encapsulates a /proc/diskstat sample. */ private static class DiskStatSample { long[] values = new long[3]; // {rsect, wsect, use} long[] changes = new long[3]; // {rsect, wsect, use} } /** * Parses the <code>proc_diskstats.log</code> file. The output from * <code>/proc/diskstat</code> is used to collect the disk statistics. * * @param is the input stream to read from * @param numCpu number of processors * @return disk statistics ({@link DiskUtilSample} and * {@link DiskTPutSample} samples) * @throws IOException if an I/O error occurs */
public static Stats parseLog(InputStream is, int numCpu)
henrysher/bootchart
src/org/bootchart/parser/linux/ProcDiskStatParser.java
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // }
import org.bootchart.common.DiskTPutSample; import org.bootchart.common.DiskUtilSample; import org.bootchart.common.Sample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common;
} if (ltime != null) { sample.changes[0] = rsect - sample.values[0]; sample.changes[1] = wsect - sample.values[1]; sample.changes[2] = use - sample.values[2]; } sample.values = new long[]{rsect, wsect, use}; line = reader.readLine(); } if (ltime != null) { long interval = time.getTime() - ltime.getTime(); interval = Math.max(interval, 1); // sum up changes for all disks long[] sums = new long[3]; for (Iterator i=diskStatMap.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i.next(); DiskStatSample sample = (DiskStatSample)entry.getValue(); for (int j=0; j<3; j++) { sums[j] += sample.changes[j]; } } // sector size is 512 B double readTPut = sums[0] / 2.0 * 1000.0 / interval; double writeTPut = sums[1] / 2.0 * 1000.0/ interval; // number of ticks (1000/s), reduced to one CPU double util = (double)sums[2] / interval / numCpu; util = Math.max(0.0, Math.min(1.0, util));
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // } // Path: src/org/bootchart/parser/linux/ProcDiskStatParser.java import org.bootchart.common.DiskTPutSample; import org.bootchart.common.DiskUtilSample; import org.bootchart.common.Sample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common; } if (ltime != null) { sample.changes[0] = rsect - sample.values[0]; sample.changes[1] = wsect - sample.values[1]; sample.changes[2] = use - sample.values[2]; } sample.values = new long[]{rsect, wsect, use}; line = reader.readLine(); } if (ltime != null) { long interval = time.getTime() - ltime.getTime(); interval = Math.max(interval, 1); // sum up changes for all disks long[] sums = new long[3]; for (Iterator i=diskStatMap.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i.next(); DiskStatSample sample = (DiskStatSample)entry.getValue(); for (int j=0; j<3; j++) { sums[j] += sample.changes[j]; } } // sector size is 512 B double readTPut = sums[0] / 2.0 * 1000.0 / interval; double writeTPut = sums[1] / 2.0 * 1000.0/ interval; // number of ticks (1000/s), reduced to one CPU double util = (double)sums[2] / interval / numCpu; util = Math.max(0.0, Math.min(1.0, util));
DiskTPutSample tputSample = new DiskTPutSample(time, readTPut, writeTPut);
henrysher/bootchart
src/org/bootchart/parser/linux/ProcNetDevParser.java
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/NetDevTPutSample.java // public class NetDevTPutSample extends DiskTPutSample { // // /* // * (non-Javadoc) // * @see org.bootchart.common.DiskTPutSample#DiskTPutSample(java.util.Date, double, double) // */ // public NetDevTPutSample(Date time, double read, double write) { // super(time, read, write); // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // }
import org.bootchart.common.NetDevTPutSample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common; import org.bootchart.common.DiskTPutSample;
/* * Bootchart -- Boot Process Visualization * * Copyright (C) 2006 Ziga Mahkovec <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.bootchart.parser.linux; /** * ProcNetDev parses log files produced by logging the output of * <code>/proc/net/dev</code>. The samples contain information about network * interface throughput, which is used for IO throughput on diskless network * stations. */ public class ProcNetDevParser { private static final Logger log = Logger.getLogger(ProcNetDevParser.class.getName()); /** NetDevSample encapsulates a /proc/net/dev sample. */ private static class NetDevSample { long[] values = new long[2]; // {rbytes, wbytes} long[] changes = new long[2]; // {rbytes, wbytes} } /** * Parses the <code>proc_netdev.log</code> file. The output from * <code>/proc/net/dev</code> is used to collect the network interface * statistics, which is returned as disk throughput statistics. * * @param is the input stream to read from * @return disk statistics {@link DiskTPutSample} samples) * @throws IOException if an I/O error occurs */
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/NetDevTPutSample.java // public class NetDevTPutSample extends DiskTPutSample { // // /* // * (non-Javadoc) // * @see org.bootchart.common.DiskTPutSample#DiskTPutSample(java.util.Date, double, double) // */ // public NetDevTPutSample(Date time, double read, double write) { // super(time, read, write); // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // } // Path: src/org/bootchart/parser/linux/ProcNetDevParser.java import org.bootchart.common.NetDevTPutSample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common; import org.bootchart.common.DiskTPutSample; /* * Bootchart -- Boot Process Visualization * * Copyright (C) 2006 Ziga Mahkovec <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.bootchart.parser.linux; /** * ProcNetDev parses log files produced by logging the output of * <code>/proc/net/dev</code>. The samples contain information about network * interface throughput, which is used for IO throughput on diskless network * stations. */ public class ProcNetDevParser { private static final Logger log = Logger.getLogger(ProcNetDevParser.class.getName()); /** NetDevSample encapsulates a /proc/net/dev sample. */ private static class NetDevSample { long[] values = new long[2]; // {rbytes, wbytes} long[] changes = new long[2]; // {rbytes, wbytes} } /** * Parses the <code>proc_netdev.log</code> file. The output from * <code>/proc/net/dev</code> is used to collect the network interface * statistics, which is returned as disk throughput statistics. * * @param is the input stream to read from * @return disk statistics {@link DiskTPutSample} samples) * @throws IOException if an I/O error occurs */
public static Stats parseLog(InputStream is)
henrysher/bootchart
src/org/bootchart/parser/linux/ProcNetDevParser.java
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/NetDevTPutSample.java // public class NetDevTPutSample extends DiskTPutSample { // // /* // * (non-Javadoc) // * @see org.bootchart.common.DiskTPutSample#DiskTPutSample(java.util.Date, double, double) // */ // public NetDevTPutSample(Date time, double read, double write) { // super(time, read, write); // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // }
import org.bootchart.common.NetDevTPutSample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common; import org.bootchart.common.DiskTPutSample;
long tbytes = Long.parseLong(tokens[9]); NetDevSample sample = (NetDevSample)diskStatMap.get(iface); if (sample == null) { sample = new NetDevSample(); diskStatMap.put(iface, sample); } if (ltime != null) { sample.changes[0] = rbytes - sample.values[0]; sample.changes[1] = tbytes - sample.values[1]; } sample.values = new long[]{rbytes, tbytes}; line = reader.readLine(); } if (ltime != null) { long interval = time.getTime() - ltime.getTime(); interval = Math.max(interval, 1); // sum up changes for all disks long[] sums = new long[2]; for (Iterator i=diskStatMap.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i.next(); NetDevSample sample = (NetDevSample)entry.getValue(); for (int j=0; j<2; j++) { sums[j] += sample.changes[j]; } } double readTPut = sums[0] * 1000.0 / interval; double writeTPut = sums[1] * 1000.0 / interval;
// Path: src/org/bootchart/common/DiskTPutSample.java // public class DiskTPutSample extends Sample { // /** Read throughput (KB/s). */ // public double read; // /** Write throughput (KB/s). */ // public double write; // // /** // * Creates a new sample. // * // * @param time sample time // * @param read read throughput // * @param write write throughput // */ // public DiskTPutSample(Date time, double read, double write) { // this.time = time != null ? new Date(time.getTime()) : null; // this.read = read; // this.write = write; // } // // /** // * Returns the string representation of the sample. // * // * @return string representation // */ // public String toString() { // return TIME_FORMAT.format(time) + "\t" + read + "\t" + write; // } // } // // Path: src/org/bootchart/common/NetDevTPutSample.java // public class NetDevTPutSample extends DiskTPutSample { // // /* // * (non-Javadoc) // * @see org.bootchart.common.DiskTPutSample#DiskTPutSample(java.util.Date, double, double) // */ // public NetDevTPutSample(Date time, double read, double write) { // super(time, read, write); // } // } // // Path: src/org/bootchart/common/Stats.java // public class Stats { // /** A list of statistics samples. */ // private List samples; // // /** // * Creates a new statistics instance. // */ // public Stats() { // samples = new ArrayList(); // } // // /** // * Adds a new statistics sample. // * // * @param sample statistics sample to add // */ // public void addSample(Sample sample) { // samples.add(sample); // } // // /** // * Returns a list of statistics samples. // * // * @return a list statistics samples // */ // public List getSamples() { // return samples; // } // } // Path: src/org/bootchart/parser/linux/ProcNetDevParser.java import org.bootchart.common.NetDevTPutSample; import org.bootchart.common.Stats; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.logging.Logger; import org.bootchart.common.Common; import org.bootchart.common.DiskTPutSample; long tbytes = Long.parseLong(tokens[9]); NetDevSample sample = (NetDevSample)diskStatMap.get(iface); if (sample == null) { sample = new NetDevSample(); diskStatMap.put(iface, sample); } if (ltime != null) { sample.changes[0] = rbytes - sample.values[0]; sample.changes[1] = tbytes - sample.values[1]; } sample.values = new long[]{rbytes, tbytes}; line = reader.readLine(); } if (ltime != null) { long interval = time.getTime() - ltime.getTime(); interval = Math.max(interval, 1); // sum up changes for all disks long[] sums = new long[2]; for (Iterator i=diskStatMap.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i.next(); NetDevSample sample = (NetDevSample)entry.getValue(); for (int j=0; j<2; j++) { sums[j] += sample.changes[j]; } } double readTPut = sums[0] * 1000.0 / interval; double writeTPut = sums[1] * 1000.0 / interval;
NetDevTPutSample tputSample = new NetDevTPutSample(time, readTPut, writeTPut);