Skip to content

Commit

Permalink
remove netflix commons
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Gordineer committed Nov 27, 2023
1 parent a634f1d commit 0ebec31
Show file tree
Hide file tree
Showing 18 changed files with 1,277 additions and 14 deletions.
1 change: 0 additions & 1 deletion ribbon-httpclient/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies {
api "org.slf4j:slf4j-api:${slf4j_version}"
api "com.netflix.servo:servo-core:${servo_version}"
api "com.google.guava:guava:${guava_version}"
api 'com.netflix.netflix-commons:netflix-commons-util:0.1.1'
testImplementation 'junit:junit:4.11'
testImplementation "org.slf4j:slf4j-log4j12:${slf4j_version}"
testImplementation 'commons-io:commons-io:2.0.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import com.netflix.http4.ssl.KeyStoreAwareSocketFactory;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.util.Pair;
import internal.com.netflix.util.Pair;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
Expand Down
2 changes: 0 additions & 2 deletions ribbon-loadbalancer/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
dependencies {
api project(':ribbon-core')
api 'com.netflix.netflix-commons:netflix-statistics:0.1.1'
api "io.reactivex:rxjava:${rx_java_version}"
api "org.slf4j:slf4j-api:${slf4j_version}"
api "com.netflix.servo:servo-core:${servo_version}"
api "com.google.guava:guava:${guava_version}"
api 'com.netflix.netflix-commons:netflix-commons-util:0.1.1'

testImplementation project(":ribbon-archaius")
testImplementation 'junit:junit:4.11'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.netflix.servo.annotations.Monitor;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.Monitors;
import com.netflix.util.concurrent.ShutdownEnabledTimer;
import internal.com.netflix.util.concurrent.ShutdownEnabledTimer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.netflix.client.config.IClientConfig;
import com.netflix.servo.monitor.Monitors;
import com.netflix.servo.monitor.Timer;
import com.netflix.util.Pair;
import internal.com.netflix.util.Pair;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package com.netflix.loadbalancer;

import com.netflix.util.Pair;
import internal.com.netflix.util.Pair;

/**
* Class that represents a typical Server (or an addressable Node) i.e. a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@

import com.google.common.annotations.VisibleForTesting;

import com.netflix.client.config.CommonClientConfigKey;
import com.netflix.client.config.IClientConfigKey;
import com.netflix.client.config.Property;
import com.netflix.client.config.UnboxedIntProperty;
import com.netflix.servo.annotations.DataSourceType;
import com.netflix.servo.annotations.Monitor;
import com.netflix.stats.distribution.DataDistribution;
import com.netflix.stats.distribution.DataPublisher;
import com.netflix.stats.distribution.Distribution;
import com.netflix.util.MeasuredRate;
import internal.com.netflix.stats.distribution.DataDistribution;
import internal.com.netflix.stats.distribution.DataPublisher;
import internal.com.netflix.stats.distribution.Distribution;
import internal.com.netflix.util.MeasuredRate;

import java.util.Date;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
*
* Copyright 2013 Netflix, 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 internal.com.netflix.stats.distribution;

import java.util.concurrent.locks.Lock;


/**
* A double-buffer of {@link DataBuffer} objects.
* One is the "current" buffer, and new data is added to it.
* The other is the "previous" buffer, and is used as a sorce
* of computed statistics.
*
* @see DataPublisher
*
* @author $Author: netflixoss $
*/
public abstract class DataAccumulator implements DataCollector {

private DataBuffer current;
private DataBuffer previous;
private final Object swapLock = new Object();

/*
* Constructor(s)
*/

/**
* Creates a new initially empty DataAccumulator.
*
* @param bufferSize the size of the buffers to use
*/
public DataAccumulator(int bufferSize) {
this.current = new DataBuffer(bufferSize);
this.previous = new DataBuffer(bufferSize);
}

/*
* Accumulating new values
*/

/** {@inheritDoc} */
public void noteValue(double val) {
synchronized (swapLock) {
Lock l = current.getLock();
l.lock();
try {
current.noteValue(val);
} finally {
l.unlock();
}
}
}

/**
* Swaps the data collection buffers, and computes statistics
* about the data collected up til now.
*/
public void publish() {
/*
* Some care is required here to correctly swap the DataBuffers,
* but not hold the synchronization object while compiling stats
* (a potentially long computation). This ensures that continued
* data collection (calls to noteValue()) will not be blocked for any
* significant period.
*/
DataBuffer tmp = null;
Lock l = null;
synchronized (swapLock) {
// Swap buffers
tmp = current;
current = previous;
previous = tmp;
// Start collection in the new "current" buffer
l = current.getLock();
l.lock();
try {
current.startCollection();
} finally {
l.unlock();
}
// Grab lock on new "previous" buffer
l = tmp.getLock();
l.lock();
}
// Release synchronizaton *before* publishing data
try {
tmp.endCollection();
publish(tmp);
} finally {
l.unlock();
}
}

/**
* Called to publish recently collected data.
* When called, the {@link Lock} associated with the "previous"
* buffer is held, so the data will not be changed.
* Other locks have been released, and so new data can be
* collected in the "current" buffer.
* The data in the buffer has also been sorted in increasing order.
*
* @param buf the {@code DataBuffer} that is now "previous".
*/
protected abstract void publish(DataBuffer buf);

} // DataAccumulator

0 comments on commit 0ebec31

Please sign in to comment.