Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2014 Dell, Inc.
   * 
   * 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 com.dell.doradus.management;
 
The Java bean class whose instances track the quantity of input requests and accumulate responses latency statistics.
 
 public class RequestsTracker {
 
 	private EventCounter rejected;
 	private EventCounter failed;
 	private TimeCounter counter;
 
 	public RequestsTracker() {
 		 = new EventCounter();
 		 = new EventCounter();
 		 = new EventCounter();
 		 = new EventCounter();
 
 		 = new TimeCounter();
 		 = new IntervalHistogram(100);
 	}
 
 	@ConstructorProperties({ "requestsExecuting""requestsRejected",
 			"requestsFailed""responseLatencyCounter",
 			"responseLatencyHistogram""lastFailureReason""lastRejectReason" })
 	public RequestsTracker(long executinglong rejectedlong failed,
 			TimeCounter counterIntervalHistogram histogram,
 			String lastFailureReasonString lastRejectReason) {
 
 		this. = new EventCounter(executing);
 		this. = new EventCounter(rejected);
 		this. = new EventCounter(failed);
 
 		this. = counter.snapshot(false);
 		this. = new EventCounter(counter.getCount());
 		this. = histogram.snapshot(false);
 
 		this. = lastFailureReason;
 		this. = lastRejectReason;
 	}

Registers new request received by server.
 
 	public synchronized void onNewRequest() {
 	}

Registers a failed request.
 
 	public synchronized void onRequestFailed(String reason) {
 		 = reason;
 	}

Registers a failed request.
 
 	public synchronized void onRequestFailed(Throwable reason) {
 		 = (reason == null) ? null : reason.getClass()
 				.getName() + ": " + reason.getMessage();
 	}

Registers an invalid request rejected by server.
 
 	public synchronized void onRequestRejected(String reason) {
 		 = reason;
 	}

Registers the successful completion of execution of request.

Parameters:
responeLatencyInMicros The response latency, in nanoseconds.
	public synchronized void onRequestSucceeded(long responeLatencyInMicros) {
		.addMicro(responeLatencyInMicros);
		.add(responeLatencyInMicros);
	}

Returns:
The number of requests currently executing.
	public long getRequestsExecuting() {
	}

Returns:
The total number of failed requests.
	public long getRequestsFailed() {
		return .getCount();
	}

Returns:
The total number of rejected requests.
	public long getRequestsRejected() {
		return .getCount();
	}

Returns:
The total number of succeeded requests.
	public long getRequestsSucceeded() {
	}

Returns:
The total number of requests.
	public long getRequestsTotal() {
	}

Returns:
The counter of latencies of responses on successfully completed requests.
		return ;
	}

Returns:
The histogram of latencies of responses on successfully completed requests.
		return ;
	}

Returns:
The reason of last reject or null, if either there are no rejects or reason was not specified at registration time of last rejected request.
	}

Returns:
The reason of last failure or null, if either there are no failures or reason was not specified at registration time of last failed request.
	}

Clones this tracker and zeroizes out it afterwards if the 'reset' is true.

Parameters:
reset zero out this tracker
Returns:
clone of this tracker
	public synchronized RequestsTracker snapshot(boolean reset) {
		long t = .getCount();
		long r = .getCount();
		long f = .getCount();
		if (reset) {
		}
		return new RequestsTracker(trfch,
	}

Zeroizes out this tracker.
	public synchronized void reset() {
	}
	public String toStr() {
		b.append("executing:  " + .getCount() + "\n");
		b.append("rejected:   " + .getCount() + "\n");
		b.append("failed:     " + .getCount() + "\n");
		b.append("succeeded:  " + .getCount() + "\n");
		b.append("total:      " + getRequestsTotal() + "\n");
		b.append("lastFailureReason:  " +  + "\n");
		b.append("lastRejectReason:   " +  + "\n");
		b.append("//\n");
		b.append("ResponseLatencyCounter: \n");
		b.append("//\n");
		b.append("ResponseLatencyHistogram: \n");
		return b.toString();
	}
New to GrepCode? Check out our FAQ X