code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
@Override
public Set<Long> keySet() {
return keySet;
} | The load factor for the map. Used to calculate {@link #maxSize}. | keySet | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public Set<Entry<Long, V>> entrySet() {
return entrySet;
} | The load factor for the map. Used to calculate {@link #maxSize}. | entrySet | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private long objectToKey(Object key) {
return (long) ((Long) key).longValue();
} | The load factor for the map. Used to calculate {@link #maxSize}. | objectToKey | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private int indexOf(long key) {
int startIndex = hashIndex(key);
int index = startIndex;
for (;;) {
if (values[index] == null) {
// It's available, so no chance that this value exists anywhere in the map.
return -1;
}
if (key == keys[index]) {
return index;
}
// Conflict, keep probing... | Locates the index for the given key. This method probes using double hashing.
@param key the key for an entry in the map.
@return the index where the key was found, or {@code -1} if no entry is found for that key. | indexOf | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private int hashIndex(long key) {
// The array lengths are always a power of two, so we can use a bitmask to stay inside the array bounds.
return hashCode(key) & mask;
} | Returns the hashed index for the given key. | hashIndex | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private static int hashCode(long key) {
return (int) (key ^ (key >>> 32));
} | Returns the hash code for the key. | hashCode | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private int probeNext(int index) {
// The array lengths are always a power of two, so we can use a bitmask to stay inside the array bounds.
return (index + 1) & mask;
} | Get the next sequential index after {@code index} and wraps if necessary. | probeNext | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private void growSize() {
size++;
if (size > maxSize) {
if (keys.length == Integer.MAX_VALUE) {
throw new IllegalStateException("Max capacity reached at size=" + size);
}
// Double the capacity.
rehash(keys.length << 1);
}
} | Grows the map size after an insertion. If necessary, performs a rehash of the map. | growSize | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private boolean removeAt(final int index) {
--size;
// Clearing the key is not strictly necessary (for GC like in a regular collection),
// but recommended for security. The memory location is still fresh in the cache anyway.
keys[index] = 0;
values[index] = null;
// In the interval from index to the next ... | Removes entry at the given index position. Also performs opportunistic, incremental rehashing if necessary to not
break conflict chains.
@param index the index position of the element to remove.
@return {@code true} if the next item was moved back. {@code false} otherwise. | removeAt | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private int calcMaxSize(int capacity) {
// Clip the upper bound so that there will always be at least one available slot.
int upperBound = capacity - 1;
return Math.min(upperBound, (int) (capacity * loadFactor));
} | Calculates the maximum size allowed before rehashing. | calcMaxSize | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
private void rehash(int newCapacity) {
long[] oldKeys = keys;
V[] oldVals = values;
keys = new long[newCapacity];
@SuppressWarnings({ "unchecked", "SuspiciousArrayCast" })
V[] temp = (V[]) new Object[newCapacity];
values = temp;
maxSize = calcMaxSize(newCapacity);
mask = newCapacity - 1;
// Insert ... | Rehashes the map for the given capacity.
@param newCapacity the new capacity for the map. | rehash | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public String toString() {
if (isEmpty()) {
return "{}";
}
StringBuilder sb = new StringBuilder(4 * size);
sb.append('{');
boolean first = true;
for (int i = 0; i < values.length; ++i) {
V value = values[i];
if (value != null) {
if (!first) {
sb.append(", ");
}
sb.append... | Rehashes the map for the given capacity.
@param newCapacity the new capacity for the map. | toString | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
protected String keyToString(long key) {
return Long.toString(key);
} | Helper method called by {@link #toString()} in order to convert a single map key into a string. This is protected
to allow subclasses to override the appearance of a given key. | keyToString | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public Iterator<Entry<Long, V>> iterator() {
return new MapIterator();
} | Set implementation for iterating over the entries of the map. | iterator | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public int size() {
return LongObjectHashMap.this.size();
} | Set implementation for iterating over the entries of the map. | size | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public int size() {
return LongObjectHashMap.this.size();
} | Set implementation for iterating over the keys. | size | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public boolean contains(Object o) {
return LongObjectHashMap.this.containsKey(o);
} | Set implementation for iterating over the keys. | contains | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public boolean remove(Object o) {
return LongObjectHashMap.this.remove(o) != null;
} | Set implementation for iterating over the keys. | remove | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public boolean retainAll(Collection<?> retainedKeys) {
boolean changed = false;
for (Iterator<PrimitiveEntry<V>> iter = entries().iterator(); iter.hasNext();) {
PrimitiveEntry<V> entry = iter.next();
if (!retainedKeys.contains(entry.key())) {
changed = true;
iter.remove();
}
}... | Set implementation for iterating over the keys. | retainAll | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public void clear() {
LongObjectHashMap.this.clear();
} | Set implementation for iterating over the keys. | clear | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public Iterator<Long> iterator() {
return new Iterator<Long>() {
private final Iterator<Entry<Long, V>> iter = entrySet.iterator();
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public Long next() {
return iter.next().getKey();
}
@Ove... | Set implementation for iterating over the keys. | iterator | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public boolean hasNext() {
return iter.hasNext();
} | Set implementation for iterating over the keys. | hasNext | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public Long next() {
return iter.next().getKey();
} | Set implementation for iterating over the keys. | next | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public void remove() {
iter.remove();
} | Set implementation for iterating over the keys. | remove | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public boolean hasNext() {
return iter.hasNext();
} | Iterator used by the {@link Map} interface. | hasNext | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
@Override
public Entry<Long, V> next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
iter.next();
return new MapEntry(iter.entryIndex);
} | Iterator used by the {@link Map} interface. | next | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/collection/type/primitive/LongObjectHashMap.java | Apache-2.0 |
public void add(long x) {
Cell[] as; long b, v; int[] hc; Cell a; int n;
if ((as = cells) != null || !casBase(b = base, b + x)) {
boolean uncontended = true;
if ((hc = threadHashCode.get()) == null ||
as == null || (n = as.length) < 1 ||
(a = as[(n... | Adds the given value.
@param x the value to add | add | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | Apache-2.0 |
public long sum() {
long sum = base;
Cell[] as = cells;
if (as != null) {
int n = as.length;
for (int i = 0; i < n; ++i) {
Cell a = as[i];
if (a != null)
sum += a.value;
}
}
return sum;
} | Returns the current sum. The returned value is <em>NOT</em> an
atomic snapshot; invocation in the absence of concurrent
updates returns an accurate result, but concurrent updates that
occur while the sum is being calculated might not be
incorporated.
@return the sum | sum | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | Apache-2.0 |
public long sumThenReset() {
long sum = base;
Cell[] as = cells;
base = 0L;
if (as != null) {
int n = as.length;
for (int i = 0; i < n; ++i) {
Cell a = as[i];
if (a != null) {
sum += a.value;
... | Equivalent in effect to {@link #sum} followed by {@link
#reset}. This method may apply for example during quiescent
points between multithreaded computations. If there are
updates concurrent with this method, the returned value is
<em>not</em> guaranteed to be the final value occurring before
the reset.
@return the s... | sumThenReset | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | Apache-2.0 |
public String toString() {
return Long.toString(sum());
} | Returns the String representation of the {@link #sum}.
@return the String representation of the {@link #sum} | toString | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | Apache-2.0 |
public long longValue() {
return sum();
} | Equivalent to {@link #sum}.
@return the sum | longValue | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/LongAdder.java | Apache-2.0 |
final boolean cas(long cmp, long val) {
return UNSAFE.compareAndSwapLong(this, valueOffset, cmp, val);
} | Padded variant of AtomicLong supporting only raw accesses plus CAS.
The value field is placed between pads, hoping that the JVM doesn't
reorder them.
JVM intrinsics note: It would be possible to use a release-only
form of CAS here, if it were provided. | cas | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | Apache-2.0 |
final boolean casBusy() {
return UNSAFE.compareAndSwapInt(this, busyOffset, 0, 1);
} | CASes the busy field from 0 to 1 to acquire lock. | casBusy | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | Apache-2.0 |
final void retryUpdate(long x, int[] hc, boolean wasUncontended) {
int h;
if (hc == null) {
threadHashCode.set(hc = new int[1]); // Initialize randomly
int r = rng.nextInt(); // Avoid zero to allow xorShift rehash
h = hc[0] = (r == 0) ? 1 : r;
}
else
... | Handles cases of updates involving initialization, resizing,
creating new Cells, and/or contention. See above for
explanation. This method suffers the usual non-modularity
problems of optimistic retry code, relying on rechecked sets of
reads.
@param x the value
@param hc the hash code holder
@param wasUncontended fals... | retryUpdate | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | Apache-2.0 |
final void internalReset(long initialValue) {
Cell[] as = cells;
base = initialValue;
if (as != null) {
int n = as.length;
for (int i = 0; i < n; ++i) {
Cell a = as[i];
if (a != null)
a.value = initialValue;
... | Sets base and all cells to the given value. | internalReset | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | Apache-2.0 |
private static sun.misc.Unsafe getUnsafe() {
try {
return sun.misc.Unsafe.getUnsafe();
} catch (SecurityException tryReflectionInstead) {}
try {
return java.security.AccessController.doPrivileged
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() ... | Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package.
Replace with a simple call to Unsafe.getUnsafe when integrating
into a jdk.
@return a sun.misc.Unsafe | getUnsafe | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | Apache-2.0 |
public sun.misc.Unsafe run() throws Exception {
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
for (java.lang.reflect.Field f : k.getDeclaredFields()) {
f.setAccessible(true);
Object x = f.get(null);
if (k... | Returns a sun.misc.Unsafe. Suitable for use in a 3rd party package.
Replace with a simple call to Unsafe.getUnsafe when integrating
into a jdk.
@return a sun.misc.Unsafe | run | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/jsr166e/Striped64.java | Apache-2.0 |
public void execute(Runnable command, long timeout, TimeUnit unit) {
submittedCount.incrementAndGet();
try {
super.execute(command);
} catch (RejectedExecutionException rx) { // NOSONAR
// not to re-throw this exception because this is only used to find out whether the pool is full, not for a
// exceptio... | Executes the given command at some time in the future. The command may execute in a new thread, in a pooled
thread, or in the calling thread, at the discretion of the <tt>Executor</tt> implementation. If no threads are
available, it will be added to the work queue. If the work queue is full, the system will wait for th... | execute | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/threadpool/QueuableCachedThreadPool.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/concurrent/threadpool/QueuableCachedThreadPool.java | Apache-2.0 |
@Override
public Writer append(final char value) {
builder.append(value);
return this;
} | Appends a single character to this Writer.
@param value The character to append
@return This writer instance | append | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
@Override
public Writer append(final CharSequence value) {
builder.append(value);
return this;
} | Appends a character sequence to this Writer.
@param value The character to append
@return This writer instance | append | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
@Override
public Writer append(final CharSequence value, final int start, final int end) {
builder.append(value, start, end);
return this;
} | Appends a portion of a character sequence to the {@link StringBuilder}.
@param value The character to append
@param start The index of the first character
@param end The index of the last character + 1
@return This writer instance | append | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
@Override
public void close() {
// no-op
} | Closing this writer has no effect. | close | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
@Override
public void flush() {
// no-op
} | Flushing this writer has no effect. | flush | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
@Override
public void write(final String value) {
if (value != null) {
builder.append(value);
}
} | Writes a String to the {@link StringBuilder}.
@param value The value to write | write | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
@Override
public void write(final char[] value, final int offset, final int length) {
if (value != null) {
builder.append(value, offset, length);
}
} | Writes a portion of a character array to the {@link StringBuilder}.
@param value The value to write
@param offset The index of the first character
@param length The number of characters to write | write | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
public StringBuilder getBuilder() {
return builder;
} | Returns the underlying builder.
@return The underlying builder | getBuilder | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
@Override
public String toString() {
return builder.toString();
} | Returns {@link StringBuilder#toString()}.
@return The contents of the String builder. | toString | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/io/type/StringBuilderWriter.java | Apache-2.0 |
public double toBytes(final long input) {
double bytes;
switch (this) {
case BYTES:
bytes = input;
break;
case KILOBYTES:
bytes = input * BYTES_PER_KILOBYTE;
break;
case MEGABYTES:
bytes = input * BYTES_PER_KILOBYTE * KILOBYTES_PER_MEGABYTE;
break;
case GIGABYTES:
bytes = input * BYTES_... | Returns the number of bytes corresponding to the provided input for a particular unit of memory.
@param input Number of units of memory.
@return Number of bytes corresponding to the provided number of particular memory units. | toBytes | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | Apache-2.0 |
public double toKiloBytes(final long input) {
double kilobytes;
switch (this) {
case BYTES:
kilobytes = input / BYTES_PER_KILOBYTE;
break;
case KILOBYTES:
kilobytes = input;
break;
case MEGABYTES:
kilobytes = input * KILOBYTES_PER_MEGABYTE;
break;
case GIGABYTES:
kilobytes = input * KIL... | Returns the number of kilobytes corresponding to the provided input for a particular unit of memory.
@param input Number of units of memory.
@return Number of kilobytes corresponding to the provided number of particular memory units. | toKiloBytes | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | Apache-2.0 |
public double toMegaBytes(final long input) {
double megabytes;
switch (this) {
case BYTES:
megabytes = input / BYTES_PER_KILOBYTE / KILOBYTES_PER_MEGABYTE;
break;
case KILOBYTES:
megabytes = input / KILOBYTES_PER_MEGABYTE;
break;
case MEGABYTES:
megabytes = input;
break;
case GIGABYTES:
... | Returns the number of megabytes corresponding to the provided input for a particular unit of memory.
@param input Number of units of memory.
@return Number of megabytes corresponding to the provided number of particular memory units. | toMegaBytes | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | Apache-2.0 |
public double toGigaBytes(final long input) {
double gigabytes;
switch (this) {
case BYTES:
gigabytes = input / BYTES_PER_KILOBYTE / KILOBYTES_PER_MEGABYTE / MEGABYTES_PER_GIGABYTE;
break;
case KILOBYTES:
gigabytes = input / KILOBYTES_PER_MEGABYTE / MEGABYTES_PER_GIGABYTE;
break;
case MEGABYTES:
... | Returns the number of gigabytes corresponding to the provided input for a particular unit of memory.
@param input Number of units of memory.
@return Number of gigabytes corresponding to the provided number of particular memory units. | toGigaBytes | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/number/SizeUnit.java | Apache-2.0 |
public static String[] fromCsvString(String line) {
List<String> row = new ArrayList<String>();
boolean inQuotedField = false;
int fieldStart = 0;
final int len = line.length();
for (int i = 0; i < len; i++) {
char c = line.charAt(i);
if (c == FIELD_SEPARATOR) {
if (!inQuotedField) { // ignore we ... | Converts CSV line to string array. | fromCsvString | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/text/CsvUtil.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/text/CsvUtil.java | Apache-2.0 |
private static void addField(List<String> row, String line, int startIndex, int endIndex, boolean inQuoted) {
String field = line.substring(startIndex, endIndex);
if (inQuoted) {
field = StringUtils.replace(field, DOUBLE_QUOTE, "\"");
}
row.add(field);
} | Converts CSV line to string array. | addField | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/text/CsvUtil.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/text/CsvUtil.java | Apache-2.0 |
public static boolean match(CharSequence string, CharSequence pattern) {
return match(string, pattern, 0, 0);
} | Checks whether a string matches a given wildcard pattern.
@param string input string
@param pattern pattern to match
@return <code>true</code> if string matches the pattern, otherwise <code>false</code> | match | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | Apache-2.0 |
public static int matchOne(String src, String... patterns) {
for (int i = 0; i < patterns.length; i++) {
if (match(src, patterns[i])) {
return i;
}
}
return -1;
} | Matches string to at least one pattern. Returns index of matched pattern, or <code>-1</code> otherwise.
@see #match(CharSequence, CharSequence) | matchOne | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | Apache-2.0 |
public static int matchPathOne(String platformDependentPath, String... patterns) {
for (int i = 0; i < patterns.length; i++) {
if (matchPath(platformDependentPath, patterns[i])) {
return i;
}
}
return -1;
} | Matches path to at least one pattern. Returns index of matched pattern or <code>-1</code> otherwise.
@see #matchPath(String, String, char) | matchPathOne | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | Apache-2.0 |
public static boolean matchPath(String path, String pattern) {
List<String> pathElements = PATH_SPLITTER.splitToList(path);
List<String> patternElements = PATH_SPLITTER.splitToList(pattern);
return matchTokens(pathElements.toArray(new String[0]), patternElements.toArray(new String[0]));
} | Matches path against pattern using *, ? and ** wildcards. Both path and the pattern are tokenized on path
separators (both \ and /). '**' represents deep tree wildcard, as in Ant. The separator should match the
corresponding path | matchPath | java | DarLiner/vjtools | vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/main/java/com/vip/vjtools/vjkit/text/WildcardMatcher.java | Apache-2.0 |
@Test
public void testIsSubClassOrInterfaceOf() {
assertTrue("TestBean should be subclass of ParentBean",
ClassUtil.isSubClassOrInterfaceOf(BClass.class, AClass.class));
assertTrue("BInterface should be subinterface of AInterface",
ClassUtil.isSubClassOrInterfaceOf(BInterface.class, AInterface.class));
a... | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | testIsSubClassOrInterfaceOf | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
@FAnnotation
public void hello4(int i) {
} | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | hello4 | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
@FAnnotation
protected void hello5(int i) {
} | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | hello5 | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
@FAnnotation
private void hello6(int i) {
} | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | hello6 | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
@FAnnotation
public void hello7(int i) {
} | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | hello7 | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
@Override
@EAnnotation
public void hello() {
// TODO Auto-generated method stub
} | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | hello | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
@FAnnotation
public void hello3(int i) {
} | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | hello3 | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
@Override
public void hello7(int i) {
} | Unit test case of {@link com.vip.vjtools.vjkit.reflect.ClassUtil#isSubClassOrInterfaceOf(Class, Class)} | hello7 | java | DarLiner/vjtools | vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | https://github.com/DarLiner/vjtools/blob/master/vjkit/src/test/java/com/vip/vjtools/vjkit/reflect/ClassUtilTest.java | Apache-2.0 |
protected String[] parseUserpass(final String userpass) {
if (userpass == null || userpass.equals("-")) {
return null;
}
int index = userpass.indexOf(':');
if (index <= 0) {
throw new RuntimeException("Unable to parse: " + userpass);
}
return new String[] { userpass.substring(0, index), userpass.subst... | Parse a 'login:password' string. Assumption is that no colon in the login name.
@param userpass
@return Array of strings with login in first position. | parseUserpass | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static Map formatCredentials(final String login, final String password) {
Map env = null;
String[] creds = new String[] { login, password };
env = new HashMap(1);
env.put(JMXConnector.CREDENTIALS, creds);
return env;
} | @param login
@param password
@return Credentials as map for RMI. | formatCredentials | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
public static JMXConnector connect(final String hostportOrPid, final String login, final String password)
throws IOException {
if (hostportOrPid.contains(":")) {// ./vjmxcli.sh - 127.0.0.1:8060 vip.jmx:type=vGCutil
JMXServiceURL rmiurl = new JMXServiceURL(
"service:jmx:rmi://" + hostportOrPid + "/jndi/rmi:... | @param login
@param password
@return Credentials as map for RMI. | connect | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected Object[] execute(final String hostport, final String login, final String password, final String beanname,
final String[] command) throws Exception {
return execute(hostport, login, password, beanname, command, false);
} | Version of execute called from the cmdline. Prints out result of execution on stdout. Parses cmdline args. Then
calls {@link #execute(String, String, String, String, String[], boolean)}.
@param args Cmdline args.
@throws Exception | execute | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
public Object[] executeOneCmd(final String hostport, final String login, final String password,
final String beanname, final String command) throws Exception {
return execute(hostport, login, password, beanname, new String[] { command }, true);
} | Version of execute called from the cmdline. Prints out result of execution on stdout. Parses cmdline args. Then
calls {@link #execute(String, String, String, String, String[], boolean)}.
@param args Cmdline args.
@throws Exception | executeOneCmd | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected Object[] execute(final String hostportOrPid, final String login, final String password,
final String beanname, String[] command, final boolean oneBeanOnly) throws Exception {
JMXConnector jmxc = connect(hostportOrPid, login, password);
Object[] result = null;
try {
MBeanServerConnection mbsc = jm... | Execute command against remote JMX agent.
@param hostportOrPid 'host:port' combination.
@param login RMI login to use.
@param password RMI password to use.
@param beanname Name of remote bean to run command against.
@param command Array of commands to run.
@param oneBeanOnly Set true if passed <code>beanname</code> is ... | execute | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
public static ObjectName getObjectName(final String beanname)
throws MalformedObjectNameException, NullPointerException {
return notEmpty(beanname) ? new ObjectName(beanname) : null;
} | Execute command against remote JMX agent.
@param hostportOrPid 'host:port' combination.
@param login RMI login to use.
@param password RMI password to use.
@param beanname Name of remote bean to run command against.
@param command Array of commands to run.
@param oneBeanOnly Set true if passed <code>beanname</code> is ... | getObjectName | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
public static boolean notEmpty(String s) {
return s != null && s.length() > 0;
} | Execute command against remote JMX agent.
@param hostportOrPid 'host:port' combination.
@param login RMI login to use.
@param password RMI password to use.
@param beanname Name of remote bean to run command against.
@param command Array of commands to run.
@param oneBeanOnly Set true if passed <code>beanname</code> is ... | notEmpty | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static Object[] doBeans(final MBeanServerConnection mbsc, final ObjectName objName,
final String[] command, final boolean oneBeanOnly) throws Exception {
Object[] result = null;
Set beans = mbsc.queryMBeans(objName, null);
if (beans.size() == 0) {
// No bean found. Check if we are to create a bean... | Execute command against remote JMX agent.
@param hostportOrPid 'host:port' combination.
@param login RMI login to use.
@param password RMI password to use.
@param beanname Name of remote bean to run command against.
@param command Array of commands to run.
@param oneBeanOnly Set true if passed <code>beanname</code> is ... | doBeans | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static Object[] doBean(MBeanServerConnection mbsc, ObjectInstance instance, String[] command)
throws Exception {
// If no command, then print out list of attributes and operations.
if (command == null || command.length <= 0) {
return new String[] { listOptions(mbsc, instance) };
}
// Maybe mult... | Get attribute or run operation against passed bean <code>instance</code>.
@param mbsc Server connection.
@param instance Bean instance we're to get attributes from or run operation against.
@param command Command to run (May be null).
@return Result. If multiple commands, multiple results.
@throws Exception | doBean | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
public static Object doSubCommand(MBeanServerConnection mbsc, ObjectInstance instance, String subCommand)
throws Exception {
// First, handle special case of our being asked to destroy a bean.
if (subCommand.equals("destroy")) {
mbsc.unregisterMBean(instance.getObjectName());
return null;
} else if (subC... | Get attribute or run operation against passed bean <code>instance</code>.
@param mbsc Server connection.
@param instance Bean instance we're to get attributes from or run operation against.
@param command Command to run (May be null).
@return Result. If multiple commands, multiple results.
@throws Exception | doSubCommand | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static boolean isFeatureInfo(MBeanFeatureInfo[] infos, String cmd) {
return getFeatureInfo(infos, cmd) != null;
} | Get attribute or run operation against passed bean <code>instance</code>.
@param mbsc Server connection.
@param instance Bean instance we're to get attributes from or run operation against.
@param command Command to run (May be null).
@return Result. If multiple commands, multiple results.
@throws Exception | isFeatureInfo | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static MBeanFeatureInfo getFeatureInfo(MBeanFeatureInfo[] infos, String cmd) {
// Cmd may be carrying arguments. Don't count them in the compare.
int index = cmd.indexOf('=');
String name = (index > 0) ? cmd.substring(0, index) : cmd;
for (int i = 0; i < infos.length; i++) {
if (infos[i].getName().... | Get attribute or run operation against passed bean <code>instance</code>.
@param mbsc Server connection.
@param instance Bean instance we're to get attributes from or run operation against.
@param command Command to run (May be null).
@return Result. If multiple commands, multiple results.
@throws Exception | getFeatureInfo | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static StringBuffer recurseTabularData(StringBuffer buffer, String indent, String name,
TabularData data) {
addNameToBuffer(buffer, indent, name);
java.util.Collection c = data.values();
for (Iterator i = c.iterator(); i.hasNext();) {
Object obj = i.next();
if (obj instanceof CompositeData) {
... | Get attribute or run operation against passed bean <code>instance</code>.
@param mbsc Server connection.
@param instance Bean instance we're to get attributes from or run operation against.
@param command Command to run (May be null).
@return Result. If multiple commands, multiple results.
@throws Exception | recurseTabularData | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static StringBuffer recurseCompositeData(StringBuffer buffer, String indent, String name,
CompositeData data) {
indent = addNameToBuffer(buffer, indent, name);
for (Iterator i = data.getCompositeType().keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
Object o = data.get(key);
... | Get attribute or run operation against passed bean <code>instance</code>.
@param mbsc Server connection.
@param instance Bean instance we're to get attributes from or run operation against.
@param command Command to run (May be null).
@return Result. If multiple commands, multiple results.
@throws Exception | recurseCompositeData | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static String addNameToBuffer(StringBuffer buffer, String indent, String name) {
if (name == null || name.length() == 0) {
return indent;
}
buffer.append(indent);
buffer.append(name);
buffer.append(":\n");
// Move all that comes under this 'name' over by one space.
return indent + " ";
} | Get attribute or run operation against passed bean <code>instance</code>.
@param mbsc Server connection.
@param instance Bean instance we're to get attributes from or run operation against.
@param command Command to run (May be null).
@return Result. If multiple commands, multiple results.
@throws Exception | addNameToBuffer | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
private void parse(String command) throws ParseException {
Matcher m = CMD_LINE_ARGS_PATTERN.matcher(command);
if (m == null || !m.matches()) {
throw new ParseException("Failed parse of " + command, 0);
}
this.cmd = m.group(1);
if (m.group(2) != null && m.group(2).length() > 0) {
this.args = m.g... | Class that parses commandline arguments. Expected format is 'operationName=arg0,arg1,arg2...'. We are assuming no
spaces nor comma's in argument values. | parse | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected String getCmd() {
return this.cmd;
} | Class that parses commandline arguments. Expected format is 'operationName=arg0,arg1,arg2...'. We are assuming no
spaces nor comma's in argument values. | getCmd | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected String[] getArgs() {
return this.args;
} | Class that parses commandline arguments. Expected format is 'operationName=arg0,arg1,arg2...'. We are assuming no
spaces nor comma's in argument values. | getArgs | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static Object doAttributeOperation(MBeanServerConnection mbsc, ObjectInstance instance, String command,
MBeanAttributeInfo[] infos) throws Exception {
// Usually we get attributes. If an argument, then we're being asked
// to set attribute.
CommandParse parse = new CommandParse(command);
if (parse.... | Class that parses commandline arguments. Expected format is 'operationName=arg0,arg1,arg2...'. We are assuming no
spaces nor comma's in argument values. | doAttributeOperation | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static Object doBeanOperation(MBeanServerConnection mbsc, ObjectInstance instance, String command,
MBeanOperationInfo[] infos) throws Exception {
// Parse command line.
CommandParse parse = new CommandParse(command);
// Get first method of name 'cmd'. Assumption is no method
// overrides. Then, lo... | Class that parses commandline arguments. Expected format is 'operationName=arg0,arg1,arg2...'. We are assuming no
spaces nor comma's in argument values. | doBeanOperation | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
protected static String listOptions(MBeanServerConnection mbsc, ObjectInstance instance)
throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
StringBuffer result = new StringBuffer();
MBeanInfo info = mbsc.getMBeanInfo(instance.getObjectName());
MBeanAttributeInfo[] attr... | Class that parses commandline arguments. Expected format is 'operationName=arg0,arg1,arg2...'. We are assuming no
spaces nor comma's in argument values. | listOptions | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
public synchronized String format(LogRecord record) {
this.buffer.setLength(0);
this.date.setTime(record.getMillis());
this.position.setBeginIndex(0);
this.formatter.format(this.date, this.buffer, this.position);
this.buffer.append(' ');
if (record.getSourceClassName() != null) {
this.buffer.appen... | Persistent buffer in which we conjure the log. | format | java | DarLiner/vjtools | vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | https://github.com/DarLiner/vjtools/blob/master/vjmxcli/src/main/java/com/vip/vjtools/jmx/Client.java | Apache-2.0 |
public static List<Long> getDelayMillsList(String schedulePlans) {
List<Long> result = new ArrayList<>();
String[] plans = StringUtils.split(schedulePlans, ',');
for (String plan : plans) {
result.add(getDelayMillis(plan));
}
return result;
} | Generate delay millis list by given plans string, separated by comma.<br/>
eg, 03:00-05:00,13:00-14:00 | getDelayMillsList | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/CleanUpScheduler.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/CleanUpScheduler.java | Apache-2.0 |
public static Date getCurrentDateByPlan(String plan, String pattern) {
try {
FastDateFormat format = FastDateFormat.getInstance(pattern);
Date end = format.parse(plan);
Calendar today = Calendar.getInstance();
end = DateUtils.setYears(end, (today.get(Calendar.YEAR)));
end = DateUtils.setMonths(end, tod... | return current date time by specified hour:minute
@param plan format: hh:mm | getCurrentDateByPlan | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/CleanUpScheduler.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/CleanUpScheduler.java | Apache-2.0 |
public void run() {
if (!valid) {
logger.warn("OldMemoryPool is not valid, task stop.");
return;
}
try {
long usedOldGenBytes = logOldGenStatus("checking oldgen status");
if (needTriggerGc(maxOldGenBytes, usedOldGenBytes, oldGenOccupancyFraction)) {
preGc();
doGc();
postGc();
}
} ca... | Detect old gen usage of current jvm periodically and trigger a cms gc if necessary.<br/>
In order to enable this feature, add these options to your target jvm:<br/>
-XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+ExplicitGCInvokesConcurrent<br/>
You can alter this class to work on a remote jvm using ... | run | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | Apache-2.0 |
private boolean needTriggerGc(long capacityBytes, long usedBytes, int occupancyFraction) {
return (occupancyFraction * capacityBytes / 100) < usedBytes;
} | Determine whether or not to trigger gc. | needTriggerGc | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | Apache-2.0 |
protected void preGc() {
logger.warn("old gen is occupied larger than occupancy fraction[{}], trying to trigger gc...",
oldGenOccupancyFraction);
} | Stuff before gc. You can override this method to do your own stuff, for example, cache clean up, deregister from register center. | preGc | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | Apache-2.0 |
protected void postGc() {
logOldGenStatus("post gc");
} | Stuff after gc. You can override this method to do your own stuff, for example, cache warmup, reregister to register center. | postGc | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | Apache-2.0 |
protected long logOldGenStatus(String hints) {
long usedOldBytes = oldGenMemoryPool.getUsage().getUsed();
logger.info(String.format("%s, max old gen:%s, used old gen:%s, current fraction: %.2f%%, gc fraction: %d%%",
hints, UnitConverter.toSizeUnit(maxOldGenBytes, 2), UnitConverter.toSizeUnit(usedOldBytes, 2),
... | Stuff after gc. You can override this method to do your own stuff, for example, cache warmup, reregister to register center. | logOldGenStatus | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | Apache-2.0 |
private MemoryPoolMXBean getOldGenMemoryPool() {
String OLD = "old";
String TENURED = "tenured";
MemoryPoolMXBean oldGenMemoryPool = null;
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getPlatformMXBeans(MemoryPoolMXBean.class);
for (MemoryPoolMXBean memoryPool : memoryPoolMXBeans) {
String... | Stuff after gc. You can override this method to do your own stuff, for example, cache warmup, reregister to register center. | getOldGenMemoryPool | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | Apache-2.0 |
private long getMemoryPoolMaxOrCommitted(MemoryPoolMXBean memoryPool) {
MemoryUsage usage = memoryPool.getUsage();
long max = usage.getMax();
return max < 0 ? usage.getCommitted() : max;
} | Stuff after gc. You can override this method to do your own stuff, for example, cache warmup, reregister to register center. | getMemoryPoolMaxOrCommitted | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/gc/ProactiveGcTask.java | Apache-2.0 |
public long count() {
long currentSecond = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime());
return count(currentSecond);
} | count request num of time window | count | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/window/TimeSlidingWindow.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/window/TimeSlidingWindow.java | Apache-2.0 |
long count(long time) {
if (time >= lastTime.get() + size) {
return 0;
}
long result = 0;
for (int i = 0; i < size; i++) {
result += counts.get(i);
}
return result;
} | count request num of time window | count | java | DarLiner/vjtools | vjstar/src/main/java/com/vip/vjstar/window/TimeSlidingWindow.java | https://github.com/DarLiner/vjtools/blob/master/vjstar/src/main/java/com/vip/vjstar/window/TimeSlidingWindow.java | Apache-2.0 |
public static String toMB(long bytes) {
if (bytes < 0) {
return "n/a";
}
return Long.toString(bytes / 1024 / 1024) + "m";
} | Formats a long value containing "number of bytes" to its megabyte representation. If the value is negative, "n/a"
will be returned. | toMB | java | DarLiner/vjtools | vjtop/src/main/java/com/vip/vjtools/vjtop/Utils.java | https://github.com/DarLiner/vjtools/blob/master/vjtop/src/main/java/com/vip/vjtools/vjtop/Utils.java | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.