Skip to content
Open
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
50 changes: 12 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,50 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.nesscomputing</groupId>
<artifactId>ness-oss-parent</artifactId>
<version>33</version>
<artifactId>ness-root</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<scm>
<connection>scm:git:git://github.com/NessComputing/components-ness-cache.git</connection>
<developerConnection>scm:git:git@github.com:NessComputing/components-ness-cache.git</developerConnection>
<url>http://github.com/NessComputing/components-ness-cache</url>
<tag>HEAD</tag>
</scm>

<groupId>com.nesscomputing.components</groupId>
<artifactId>ness-cache</artifactId>
<name>ness-cache</name>
<version>1.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Ness Caching Component</description>

<properties>
<dep.jackson.version>2.2.3</dep.jackson.version>
<dep.discovery.version>1.6.2</dep.discovery.version>
<basepom.test.fork-count>1</basepom.test.fork-count>
<basepom.test.reuse-vm>false</basepom.test.reuse-vm>
</properties>

<dependencies>
<dependency>
<groupId>com.nesscomputing.components</groupId>
<artifactId>ness-jackson</artifactId>
<version>2.3.3</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.nesscomputing.components</groupId>
<artifactId>ness-logging</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>com.nesscomputing.components</groupId>
<artifactId>ness-lifecycle</artifactId>
<version>1.3.0</version>
</dependency>

<dependency>
<groupId>com.nesscomputing.components</groupId>
<artifactId>ness-config</artifactId>
<version>2.3.1</version>
</dependency>

<dependency>
<groupId>com.nesscomputing.service.discovery</groupId>
<artifactId>discovery-client</artifactId>
<version>${dep.discovery.version}</version>
</dependency>

<dependency>
<groupId>net.spy</groupId>
<artifactId>spymemcached</artifactId>
<version>2.10.1</version>
</dependency>

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.6</version>
</dependency>

<!-- Guice and Guava -->
Expand All @@ -87,13 +66,12 @@
<!-- Misc -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<artifactId>annotations</artifactId>
</dependency>

<dependency>
<groupId>org.weakref</groupId>
<artifactId>jmxutils</artifactId>
<version>1.12</version>
</dependency>

<dependency>
Expand All @@ -111,25 +89,17 @@
<artifactId>config-magic</artifactId>
</dependency>

<dependency>
<groupId>com.nesscomputing.testing</groupId>
<artifactId>findbugs-annotations</artifactId>
<optional>true</optional>
<version>2.0.0</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${dep.jackson.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-smile</artifactId>
<version>${dep.jackson.version}</version>
<scope>runtime</scope>
</dependency>

<!-- Test deps -->

<dependency>
Expand All @@ -138,10 +108,15 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.nesscomputing.components</groupId>
<artifactId>ness-jackson</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.thimbleware.jmemcached</groupId>
<artifactId>jmemcached-core</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>

Expand All @@ -160,7 +135,6 @@
<dependency>
<groupId>com.nesscomputing.service.discovery</groupId>
<artifactId>discovery-testing</artifactId>
<version>${dep.discovery.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
34 changes: 19 additions & 15 deletions src/main/java/com/nesscomputing/cache/Base64.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ final class Base64
private Base64() {
}

static private final int BASELENGTH = 255;
static private final int LOOKUPLENGTH = 64;
static private final int TWENTYFOURBITGROUP = 24;
static private final int EIGHTBIT = 8;
static private final int SIXTEENBIT = 16;
// static private final int SIXBIT = 6;
static private final int FOURBYTE = 4;
static private final int SIGN = -128;
static private final byte PAD = (byte) '=';
static private byte [] base64Alphabet = new byte[BASELENGTH];
static private byte [] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
private static final int BASELENGTH = 255;
private static final int LOOKUPLENGTH = 64;
private static final int TWENTYFOURBITGROUP = 24;
private static final int EIGHTBIT = 8;
private static final int SIXTEENBIT = 16;
// private static final int SIXBIT = 6;
private static final int FOURBYTE = 4;
private static final int SIGN = -128;
private static final byte PAD = (byte) '=';
private static byte [] base64Alphabet = new byte[BASELENGTH];
private static byte [] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];

static
{
Expand All @@ -72,14 +72,17 @@ private Base64() {
base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;

for (int i = 0; i <= 25; i++ )
for (int i = 0; i <= 25; i++ ) {
lookUpBase64Alphabet[i] = (byte) ('A' + i);
}

for (int i = 26, j = 0; i <= 51; i++, j++ )
for (int i = 26, j = 0; i <= 51; i++, j++ ) {
lookUpBase64Alphabet[i] = (byte) ('a'+ j);
}

for (int i = 52, j = 0; i <= 61; i++, j++ )
for (int i = 52, j = 0; i <= 61; i++, j++ ) {
lookUpBase64Alphabet[i] = (byte) ('0' + j);
}

lookUpBase64Alphabet[62] = (byte) '+';
lookUpBase64Alphabet[63] = (byte) '/';
Expand Down Expand Up @@ -107,8 +110,9 @@ public static boolean isArrayByteBase64( byte[] arrayOctect )
}
for (int i=0; i < length; i++)
{
if ( !Base64.isBase64(arrayOctect[i]) )
if ( !Base64.isBase64(arrayOctect[i]) ) {
return false;
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public String getMemcachedSeparator() {
@Config({"ness.cache.${cacheName}.max-value-size", "ness.cache.max-value-size"})
@Default("1034240")
public int getMemcachedMaxValueSize() {
return 1034240;
return 1034240;
}

@Config({"ness.cache.${cacheName}.read-queue", "ness.cache.read-queue"})
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/nesscomputing/cache/CacheModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
import com.google.inject.Scopes;
import com.google.inject.name.Names;

import org.apache.commons.lang3.StringUtils;

import com.nesscomputing.config.Config;
import com.nesscomputing.config.ConfigProvider;
import com.nesscomputing.logging.Log;

import org.apache.commons.lang3.StringUtils;

public class CacheModule extends AbstractModule {
private static final Log LOG = Log.findLog();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/nesscomputing/cache/CacheStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import javax.annotation.concurrent.ThreadSafe;

import org.weakref.jmx.Managed;

import com.nesscomputing.logging.Log;

import org.weakref.jmx.Managed;

/**
* Bean to hold cache statistics on a per-namespace basis
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/nesscomputing/cache/CacheStores.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import java.util.Arrays;
import java.util.Collection;

import org.joda.time.DateTime;

import javax.annotation.Nonnull;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;

import org.joda.time.DateTime;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@SuppressFBWarnings("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE")
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/com/nesscomputing/cache/CacheTopologyProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.nesscomputing.cache;

import com.nesscomputing.logging.Log;

import java.net.InetSocketAddress;
import java.net.URI;
import java.util.Collection;
Expand All @@ -25,11 +23,6 @@

import javax.annotation.Nonnull;

import com.nesscomputing.service.discovery.client.ReadOnlyDiscoveryClient;
import com.nesscomputing.service.discovery.client.ServiceInformation;

import org.apache.commons.lang3.StringUtils;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
Expand All @@ -39,6 +32,12 @@
import com.google.inject.Singleton;
import com.google.inject.name.Named;

import com.nesscomputing.logging.Log;
import com.nesscomputing.service.discovery.client.ReadOnlyDiscoveryClient;
import com.nesscomputing.service.discovery.client.ServiceInformation;

import org.apache.commons.lang3.StringUtils;

/**
* Use service discovery or configuration to assemble a set of Memcache servers dynamically.
*/
Expand All @@ -48,7 +47,7 @@ class CacheTopologyProvider {
@Override
public InetSocketAddress apply(@Nonnull ServiceInformation input) {
return new InetSocketAddress(input.getProperty(ServiceInformation.PROP_SERVICE_ADDRESS),
Integer.valueOf(input.getProperty(ServiceInformation.PROP_SERVICE_PORT)));
Integer.parseInt(input.getProperty(ServiceInformation.PROP_SERVICE_PORT)));
}
};

Expand Down Expand Up @@ -87,10 +86,10 @@ public ImmutableList<InetSocketAddress> get() {

final Collection<ServiceInformation> serviceInformation;
if (cacheName == null) {
serviceInformation = discoveryClient.findAllServiceInformation("memcached");
serviceInformation = discoveryClient.findAllServiceInformation("memcached");
}
else {
serviceInformation = discoveryClient.findAllServiceInformation("memcached", cacheName);
serviceInformation = discoveryClient.findAllServiceInformation("memcached", cacheName);
}

//apply strict typing
Expand All @@ -107,7 +106,7 @@ public boolean apply(final ServiceInformation input) {
});

final List<InetSocketAddress> results = Lists.newArrayList(Collections2.transform(discoverInformation, SERVICE_INFORMATION_TO_INET_SOCKET_ADDRESS));
Collections.sort(results, InetSocketAddressComparator.DEFAULT);
return ImmutableList.copyOf(results);
Collections.sort(results, InetSocketAddressComparator.DEFAULT);
return ImmutableList.copyOf(results);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.weakref.jmx.MBeanExporter;

import com.nesscomputing.lifecycle.Lifecycle;
import com.nesscomputing.lifecycle.LifecycleListener;
import com.nesscomputing.lifecycle.LifecycleStage;
import com.nesscomputing.logging.Log;

import org.weakref.jmx.MBeanExporter;

/**
* Manage various {@link CacheStatistics} beans exported via JMX. Exports them on first access,
* and unexports them on lifecycle shutdown.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/nesscomputing/cache/JvmCacheProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;

import com.nesscomputing.lifecycle.Lifecycle;
import com.nesscomputing.lifecycle.LifecycleListener;
import com.nesscomputing.lifecycle.LifecycleStage;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
Expand All @@ -36,10 +40,6 @@

import org.joda.time.DateTime;

import com.nesscomputing.lifecycle.Lifecycle;
import com.nesscomputing.lifecycle.LifecycleListener;
import com.nesscomputing.lifecycle.LifecycleStage;

/**
* An in-JVM cache, currently backed by EHCache
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/nesscomputing/cache/MemcacheProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;

import com.nesscomputing.logging.Log;

import net.spy.memcached.MemcachedClient;
import net.spy.memcached.OperationTimeoutException;

import org.joda.time.DateTime;

import com.nesscomputing.logging.Log;


/**
* Provide a cache based upon a memached server
Expand Down
Loading