Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

General tidy up no functional change #530

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,6 @@ CONFIG_ROOT := $(STYX_HOME)/conf/env-$(STACK)
release-styx: release-no-tests
unzip -oq `find distribution/target -maxdepth 1 -name "styx*.zip"` -d $(dir ${STYX_HOME})

## Stops running netty-based origins (i.e. the origins started by start-origins)
stop-origins:
(support/origins-starter-app/bin/styx-originsstopper.sh 2>&1)

## Starts netty-based origins (release-styx needs to have been run first)
start-origins: release-styx stop-origins
(support/origins-starter-app/bin/styx-originsstarter.sh $(STYX_HOME) $(CONFIG_ROOT)/styx-config.yml &)

## Start with netty-based origins running on the ports Styx expects to find them
start-with-origins: release-styx start-origins
$(STYX_HOME)/bin/startup \
-e $(CONFIG_ROOT)/styx-env.sh \
-l $(CONFIG_ROOT)/logback.xml \
$(CONFIG_ROOT)/styx-config.yml

## Start with no origins (they can be launched separately if desired)
start: release-styx
$(STYX_HOME)/bin/startup \
-e $(CONFIG_ROOT)/styx-env.sh \
-l $(CONFIG_ROOT)/logback.xml \
$(CONFIG_ROOT)/styx-config.yml

## Build site-docs
docs:
mvn clean site:site
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,35 +15,16 @@
*/
package com.hotels.styx.client.healthcheck;

import com.hotels.styx.api.Id;
import com.hotels.styx.api.extension.Origin;
import com.hotels.styx.api.extension.service.HealthCheckConfig;
import com.hotels.styx.api.extension.service.spi.StyxService;
import com.hotels.styx.client.HttpClient;

import java.util.EventListener;
import java.util.Set;
import java.util.function.Supplier;

/**
* Monitors the health of origins.
*/
public interface OriginHealthStatusMonitor extends StyxService {
/**
* Factory for creating a health monitor of an origin.
*/
interface Factory {
/**
* Create health monitor of an origin with the given config and health checking function.
*
* @param id the backend service id
* @param healthCheckConfig configuration of the health check
* @param healthCheckFunction a function that decides if the origin is healthy or not
* @param client client that will perform the health-check
* @return the monitor of the origin
*/
OriginHealthStatusMonitor create(Id id, HealthCheckConfig healthCheckConfig, Supplier<OriginHealthCheckFunction> healthCheckFunction, HttpClient client);
}

/**
* An event listener that receives notifications of origin healthiness, unhealthiness and when monitoring for an origin stops.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,8 +34,8 @@
/**
* Factory that produces {@link OriginHealthStatusMonitor}s based on configuration.
*/
public final class OriginHealthStatusMonitorFactory implements OriginHealthStatusMonitor.Factory {
@Override
public final class OriginHealthStatusMonitorFactory {

public OriginHealthStatusMonitor create(Id id, HealthCheckConfig healthCheckConfig, Supplier<OriginHealthCheckFunction> healthCheckFunction, HttpClient client) {
if (healthCheckConfig == null || !healthCheckConfig.isEnabled()) {
return new NoOriginHealthStatusMonitor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.hotels.styx.api.Requests;
import com.hotels.styx.api.exceptions.TransportLostException;
import com.hotels.styx.api.extension.Origin;
import com.hotels.styx.client.Operation;
import com.hotels.styx.client.OriginStatsFactory;
import com.hotels.styx.common.format.HttpMessageFormatter;
import com.hotels.styx.common.format.SanitisedHttpMessageFormatter;
Expand Down Expand Up @@ -61,7 +60,7 @@
/**
* An operation that writes an HTTP request to an origin.
*/
public class HttpRequestOperation implements Operation<NettyConnection, LiveHttpResponse> {
public class HttpRequestOperation {
private static final String IDLE_HANDLER_NAME = "idle-handler";
private static final Logger LOGGER = getLogger(HttpRequestOperation.class);

Expand Down Expand Up @@ -128,7 +127,6 @@ private static boolean requestIsOngoing(RequestBodyChunkSubscriber bodyChunkSubs
return bodyChunkSubscriber != null && bodyChunkSubscriber.requestIsOngoing();
}

@Override
public Observable<LiveHttpResponse> execute(NettyConnection nettyConnection) {
AtomicReference<RequestBodyChunkSubscriber> requestRequestBodyChunkSubscriber = new AtomicReference<>();
requestTime = System.currentTimeMillis();
Expand Down Expand Up @@ -203,7 +201,6 @@ public int hashCode() {
return Objects.hash(request);
}


@Override
public boolean equals(Object obj) {
if (this == obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@
import com.hotels.styx.api.extension.service.spi.StyxService;
import com.hotels.styx.infrastructure.MemoryBackedRegistry;
import com.hotels.styx.proxy.plugin.NamedPlugin;
import com.hotels.styx.routing.HttpPipelineFactory;
import com.hotels.styx.routing.RoutingObject;
import com.hotels.styx.routing.RoutingObjectRecord;
import com.hotels.styx.routing.StaticPipelineFactory;
import com.hotels.styx.routing.config.Builtins;
import com.hotels.styx.routing.config.RoutingObjectFactory;
import com.hotels.styx.routing.config.StyxObjectConfiguration;
import com.hotels.styx.routing.db.StyxObjectStore;
import com.hotels.styx.routing.handlers.HttpInterceptorPipeline;
import com.hotels.styx.startup.PipelineFactory;
import com.hotels.styx.startup.StyxServerComponents;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.SocketChannel;

Expand All @@ -48,9 +42,8 @@
/**
* Produces the pipeline for the Styx proxy server.
*/
public final class StyxPipelineFactory implements PipelineFactory {
public final class StyxPipelineFactory {

private final StyxObjectStore<RoutingObjectRecord> routeDb;
private final RoutingObjectFactory.Context builtinRoutingObjects;
private final Environment environment;
private final Map<String, StyxService> services;
Expand All @@ -60,14 +53,12 @@ public final class StyxPipelineFactory implements PipelineFactory {


public StyxPipelineFactory(
StyxObjectStore<RoutingObjectRecord> routeDb,
RoutingObjectFactory.Context builtinRoutingObjects,
Environment environment,
Map<String, StyxService> services,
List<NamedPlugin> plugins,
EventLoopGroup eventLoopGroup,
Class<? extends SocketChannel> nettySocketChannelClass) {
this.routeDb = requireNonNull(routeDb);
this.builtinRoutingObjects = requireNonNull(builtinRoutingObjects);
this.environment = requireNonNull(environment);
this.services = requireNonNull(services);
Expand All @@ -76,8 +67,7 @@ public StyxPipelineFactory(
this.nettySocketChannelClass = requireNonNull(nettySocketChannelClass);
}

@Override
public HttpHandler create(StyxServerComponents config) {
public HttpHandler create() {
boolean requestTracking = environment.configuration().get("requestTracking", Boolean.class).orElse(false);

return new HttpInterceptorPipeline(
Expand All @@ -91,23 +81,18 @@ private RoutingObject configuredPipeline(RoutingObjectFactory.Context routingObj

Optional<JsonNode> rootHandlerNode = environment.configuration().get("httpPipeline", JsonNode.class);

HttpPipelineFactory pipelineBuilder = rootHandlerNode
.map(jsonNode -> {
StyxObjectConfiguration node = toRoutingConfigNode(jsonNode);
return (HttpPipelineFactory) () -> Builtins.build(ImmutableList.of("httpPipeline"), routingObjectFactoryContext, node);
})
.orElseGet(() -> {
Registry<BackendService> registry = (Registry<BackendService>) services.get("backendServiceRegistry");

return new StaticPipelineFactory(
environment,
registry != null ? registry : new MemoryBackedRegistry<>(),
plugins,
eventLoopGroup,
nettySocketChannelClass,
requestTracking);
});

return pipelineBuilder.build();
if (rootHandlerNode.isPresent()) {
return Builtins.build(ImmutableList.of("httpPipeline"), routingObjectFactoryContext, toRoutingConfigNode(rootHandlerNode.get()));
}

Registry<BackendService> registry = (Registry<BackendService>) services.get("backendServiceRegistry");
return new StaticPipelineFactory(
environment,
registry != null ? registry : new MemoryBackedRegistry<>(),
plugins,
eventLoopGroup,
nettySocketChannelClass,
requestTracking)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public StyxServer(StyxServerComponents components, Stopwatch stopwatch) {

ProxyServerSetUp proxyServerSetUp = new ProxyServerSetUp(
new StyxPipelineFactory(
components.routeDatabase(),
components.routingObjectFactoryContext(),
components.environment(),
components.services(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,6 @@
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.hotels.styx.api.Resource;
import com.hotels.styx.api.extension.service.BackendService;
import com.hotels.styx.applications.ApplicationsProvider;
import com.hotels.styx.applications.BackendServices;

import java.io.IOException;
Expand All @@ -38,7 +37,7 @@
* Provides applications by reading from a YAML file.
*
*/
public class YamlApplicationsProvider implements ApplicationsProvider {
public class YamlApplicationsProvider {
private static final ObjectMapper MAPPER = addStyxMixins(new ObjectMapper(new YAMLFactory()));
private static final CollectionType TYPE = MAPPER.getTypeFactory().constructCollectionType(List.class, BackendService.class);

Expand Down Expand Up @@ -82,7 +81,6 @@ public static BackendServices loadApplicationsFrom(String path) {
return loadFromPath(path).get();
}

@Override
public BackendServices get() {
return backendServices;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Builds a static "backwards compatibility" pipeline which is just a sequence of plugins
* followed by backend service proxy.
*/
public class StaticPipelineFactory implements HttpPipelineFactory {
public class StaticPipelineFactory {
private final BackendServiceClientFactory clientFactory;
private final Environment environment;
private final Registry<BackendService> registry;
Expand Down Expand Up @@ -73,7 +73,6 @@ private static BackendServiceClientFactory createClientFactory(Environment envir
return new StyxBackendServiceClientFactory(environment);
}

@Override
public RoutingObject build() {
BackendServicesRouter backendServicesRouter = new BackendServicesRouter(clientFactory, environment, eventLoopGroup, nettySocketChannelClass);
registry.addListener(backendServicesRouter);
Expand Down

This file was deleted.

Loading