All Projects → AdamBien → Porcupine

AdamBien / Porcupine

Licence: apache-2.0
Threading, Resiliency and Monitoring for Java EE 7/8

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Porcupine

Micro
Micro is a distributed cloud operating system
Stars: ✭ 10,778 (+10786.87%)
Mutual labels:  microservices, cloud, cloud-native
Nff Go
NFF-Go -Network Function Framework for GO (former YANFF)
Stars: ✭ 1,036 (+946.46%)
Mutual labels:  microservices, cloud, cloud-native
Examples
Demo applications and code examples for Confluent Platform and Apache Kafka
Stars: ✭ 571 (+476.77%)
Mutual labels:  microservices, cloud, monitoring
Vald
Vald. A Highly Scalable Distributed Vector Search Engine
Stars: ✭ 158 (+59.6%)
Mutual labels:  microservices, cloud, cloud-native
Micrometer
An application metrics facade for the most popular monitoring tools. Think SLF4J, but for metrics.
Stars: ✭ 3,173 (+3105.05%)
Mutual labels:  microservices, cloud-native, monitoring
Swagger Stats
API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
Stars: ✭ 559 (+464.65%)
Mutual labels:  microservices, statistics, monitoring
Devops Readme.md
What to Read to Learn More About DevOps
Stars: ✭ 398 (+302.02%)
Mutual labels:  cloud, cloud-native, monitoring
Kubevious
Kubevious - application centric Kubernetes UI and continuous assurance provider
Stars: ✭ 869 (+777.78%)
Mutual labels:  microservices, cloud, cloud-native
Jaeger Client Go
Jaeger Bindings for Go OpenTracing API.
Stars: ✭ 1,035 (+945.45%)
Mutual labels:  microservices, monitoring
Cloud Native Labs
The Labs for Cloud Native Roadshow on OpenShift https://www.openshift.com/
Stars: ✭ 64 (-35.35%)
Mutual labels:  microservices, cloud-native
Awesome Cloud Native
A curated list for awesome cloud native tools, software and tutorials. - https://jimmysong.io/awesome-cloud-native/
Stars: ✭ 1,157 (+1068.69%)
Mutual labels:  microservices, cloud-native
Grpcjsontranscoder
A filter which allows a RESTful JSON API client to send requests to .NET web server over HTTP and get proxied to a gRPC service
Stars: ✭ 97 (-2.02%)
Mutual labels:  microservices, cloud-native
Kumuluzee Samples
KumuluzEE samples demonstrate how to get started using KumuluzEE microservice framework. They provide small, specific, working samples that can be used as a reference for your own projects.
Stars: ✭ 47 (-52.53%)
Mutual labels:  microservices, cloud-native
Domonit
A Deadly Simple Docker Monitoring Wrapper For Docker API
Stars: ✭ 67 (-32.32%)
Mutual labels:  cloud, monitoring
Pacbot
PacBot (Policy as Code Bot)
Stars: ✭ 1,017 (+927.27%)
Mutual labels:  cloud, cloud-native
Awesome Cloud Native Tutorials
A curated list of tutorials and labs for learning cloud native concepts
Stars: ✭ 70 (-29.29%)
Mutual labels:  cloud, cloud-native
Kardia
A humane service status API module to expose any operational/internals of any Node.js based microservice. JSON format over HTTP protocol.
Stars: ✭ 70 (-29.29%)
Mutual labels:  microservices, monitoring
Cloudserver
Zenko CloudServer, an open-source Node.js implementation of the Amazon S3 protocol on the front-end and backend storage capabilities to multiple clouds, including Azure and Google.
Stars: ✭ 1,167 (+1078.79%)
Mutual labels:  cloud, cloud-native
Health Checks Api
Standardize the way services and applications expose their status in a distributed application
Stars: ✭ 78 (-21.21%)
Mutual labels:  microservices, monitoring
Siddhi
Stream Processing and Complex Event Processing Engine
Stars: ✭ 1,185 (+1096.97%)
Mutual labels:  cloud, cloud-native

porcupine

Configurable threading, resiliency and monitoring with injectable statistics for Java EE 7. Porcupine is the implementation of the bulkhead and handshaking patterns for Java EE 7.

Features:

  1. Conventional: ExecutorService is directly injectable. The thread pool derives the name from the field, but can be easily overridden.
  2. Drop-in install: a single dependency in the pom.xml is sufficient.
  3. Standard based: porcupine uses JSR 236: Concurrency Utilities for JavaTM EE
  4. Small: the entire framework is: 16kB.
  5. Extensible without configuration: All major components can be replaced (big thanks to @Specializes)

Booting Porcupine

Intro

Configuration

Configuration

Dealing with Overload

Overload

Automatic Statistics Injection

Overload

##Installation

        <dependency>
            <groupId>com.airhacks</groupId>
            <artifactId>porcupine</artifactId>
            <version>NEWEST_VERSION</version>
            <scope>compile</scope>
        </dependency>

With statistics injection into HTTP headers of all JAX-RS resources:

        <dependency>
            <groupId>com.airhacks</groupId>
            <artifactId>porcupine-spy</artifactId>
            <version>NEWEST_VERSION</version>
            <scope>compile</scope>
        </dependency>

##Conventional Usage

@Stateless
public class MessagesService {

    @Inject
    @Dedicated
    ExecutorService light;

    @Inject
    @Dedicated
    ExecutorService heavy;

Custom naming is also supported:

    @Inject
    @Dedicated("custom-pool")
    private ExecutorService first;

##Statistics and monitoring

###Exposure

@Path("statistics")
@RequestScoped
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public class StatisticsResource {

    @Inject
    Instance<List<Statistics>> statistics;

	@GET
    public List<Statistics> expose() {
        return this.statistics.get();
	}

}

###Sample output

Unified thread pool statistics are accessible via injection. Individual statistics are injectable with the @Dedicated qualifier.

XML statistics

<statistics>
	<pipelineName>light</pipelineName>
	<remainingQueueCapacity>100</remainingQueueCapacity>
	<completedTaskCount>1</completedTaskCount>
	<activeThreadCount>0</activeThreadCount>
	<largestThreadPoolSize>1</largestThreadPoolSize>
	<currentThreadPoolSize>1</currentThreadPoolSize>
	<totalNumberOfTasks>1</totalNumberOfTasks>
	<maximumPoolSize>48</maximumPoolSize>
	<rejectedExecutionHandlerName>ExecutorServiceExposer$$Lambda$3/1562863014</rejectedExecutionHandlerName>
	<rejectedTasks>0</rejectedTasks>
</statistics>
<statistics>
	<pipelineName>heavy</pipelineName>
	<remainingQueueCapacity>16</remainingQueueCapacity>
	<completedTaskCount>0</completedTaskCount>
	<activeThreadCount>1</activeThreadCount>
	<largestThreadPoolSize>1</largestThreadPoolSize>
	<currentThreadPoolSize>1</currentThreadPoolSize>
	<totalNumberOfTasks>1</totalNumberOfTasks>
	<maximumPoolSize>8</maximumPoolSize>
	<rejectedExecutionHandlerName>CallerRunsPolicy</rejectedExecutionHandlerName>
	<rejectedTasks>0</rejectedTasks>
</statistics>

JSON statistics

[{
        "pipelineName": "light",
        "remainingQueueCapacity": 100,
        "completedTaskCount": 1,
        "activeThreadCount": 0,
        "largestThreadPoolSize": 1,
        "currentThreadPoolSize": 1,
        "totalNumberOfTasks": 1,
        "maximumPoolSize": 48,
        "rejectedExecutionHandlerName": "ExecutorServiceExposer$$Lambda$3/1562863014",
        "rejectedTasks": 0
    },
    {
        "pipelineName": "heavy",
        "remainingQueueCapacity": 16,
        "completedTaskCount": 1,
        "activeThreadCount": 0,
        "largestThreadPoolSize": 1,
        "currentThreadPoolSize": 1,
        "totalNumberOfTasks": 1,
        "maximumPoolSize": 8,
        "rejectedExecutionHandlerName": "CallerRunsPolicy",
        "rejectedTasks": 0
    }]

Custom configuration (fully optional)

@Specializes
public class CustomExecutorConfigurator extends ExecutorConfigurator {

    @Override
    public ExecutorConfiguration defaultConfigurator() {
        return super.defaultConfigurator();
    }

    @Override
    public ExecutorConfiguration forPipeline(String name) {
        if ("heavy".equals(name)) {
            return new ExecutorConfiguration.Builder().
                    corePoolSize(4).
                    maxPoolSize(8).
                    queueCapacity(16).
                    keepAliveTime(1).
                    callerRunsPolicy().
                    build();
        }
        return super.forPipeline(name);
    }

}

Statistics Injection into HTTP Headers

HTTP/1.1 200 OK
Server: GlassFish Server Open Source Edition  4.1 
X-Powered-By: Servlet/3.1 JSP/2.3 (GlassFish Server Open Source Edition  4.1  Java/Oracle Corporation/1.8)
x-porcupine-statistics-light: {"pipelineName":"light","activeThreadCount":1,"completedTaskCount":1,
"corePoolSize":8,"currentThreadPoolSize":2,"largestThreadPoolSize":2,"maximumPoolSize":16,"rejectedTasks":0,
"remainingQueueCapacity":100,"minQueueCapacity":100,"totalNumberOfTasks":2}
x-porcupine-statistics-heavy: {"pipelineName":"heavy","rejectedExecutionHandlerName":"CallerRunsPolicy",
"activeThreadCount":0,"completedTaskCount":1,"corePoolSize":4,"currentThreadPoolSize":1,
"largestThreadPoolSize":1,"maximumPoolSize":8,"rejectedTasks":0,"remainingQueueCapacity":16,
"minQueueCapacity":16,"totalNumberOfTasks":1}
Content-Type: text/plain
Date: Wed, 18 Mar 2015 07:50:20 GMT
Content-Length: 36
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].