-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HWKMETRICS-99: allow Hawkular metrics to start and then wait for a Ca…
…ssandra cluster to become available rather than just failing.
- Loading branch information
Showing
6 changed files
with
371 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...axrs/src/main/java/org/hawkular/metrics/api/jaxrs/filter/CassandraAvailabilityFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2014-2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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.hawkular.metrics.api.jaxrs.filter; | ||
|
||
import org.hawkular.metrics.api.jaxrs.ApiError; | ||
import org.hawkular.metrics.core.api.MetricsService; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerRequestFilter; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.Provider; | ||
import java.io.IOException; | ||
|
||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE; | ||
|
||
/** | ||
* Created by mwringe on 20/05/15. | ||
*/ | ||
@Provider | ||
public class CassandraAvailabilityFilter implements ContainerRequestFilter { | ||
|
||
private static final String NO_CASSANDRA_SESSION_MSG = "Service unavailable while initializing."; | ||
|
||
@Inject | ||
private MetricsService metricsService; | ||
|
||
|
||
@Override | ||
public void filter(ContainerRequestContext containerRequestContext) throws IOException { | ||
if (!metricsService.isStarted()) { | ||
// Fail since the Cassandra cluster is not yet up yet. | ||
Response response = Response.status(Response.Status.SERVICE_UNAVAILABLE) | ||
.type(APPLICATION_JSON_TYPE) | ||
.entity(new ApiError(NO_CASSANDRA_SESSION_MSG)) | ||
.build(); | ||
containerRequestContext.abortWith(response); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
core/metrics-core-impl/src/main/java/org/hawkular/metrics/core/impl/HawkularMetrics.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.