Skip to content

Commit efd42d5

Browse files
committed
INTERNAL: Remove public ArcusClient constructor.
1 parent a613d67 commit efd42d5

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/main/java/net/spy/memcached/ArcusClient.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,39 @@ protected static ArcusClient getInstance(ConnectionFactory cf,
340340
return new ArcusClient(cf, name, addrs);
341341
}
342342

343+
/**
344+
* Create an Arcus client for the given memcached server addresses.
345+
* Recommend only invoked with proxy arcus server.
346+
* @param addrs socket addresses for the proxy memcached servers
347+
* @param cfb connection factory builder to configure connections for this client
348+
* @return Arcus client instance
349+
* @throws IOException
350+
*/
351+
public static ArcusClient createArcusClient(List<InetSocketAddress> addrs,
352+
ConnectionFactoryBuilder cfb)
353+
throws IOException {
354+
return new ArcusClient(cfb.build(), addrs);
355+
}
356+
357+
/**
358+
* Create an Arcus client pool for the given memcached server addresses.
359+
* Recommend only invoked with proxy arcus server.
360+
* @param addrs socket addresses for the proxy memcached servers
361+
* @param cfb connection factory builder to configure connections for this client
362+
* @param size pool size
363+
* @return Arcus client pool instance
364+
* @throws IOException
365+
*/
366+
public static ArcusClientPool createArcusClientPool(List<InetSocketAddress> addrs,
367+
ConnectionFactoryBuilder cfb, int size)
368+
throws IOException {
369+
ArcusClient[] clients = new ArcusClient[size];
370+
for (int i = 0; i < size; i++) {
371+
clients[i] = new ArcusClient(cfb.build(), addrs);
372+
}
373+
return new ArcusClientPool(size, clients);
374+
}
375+
343376
/**
344377
* Create an Arcus client for the given memcached server addresses.
345378
*
@@ -348,7 +381,7 @@ protected static ArcusClient getInstance(ConnectionFactory cf,
348381
* @param addrs socket addresses for the memcached servers
349382
* @throws IOException if connections cannot be established
350383
*/
351-
public ArcusClient(ConnectionFactory cf, String name, List<InetSocketAddress> addrs)
384+
protected ArcusClient(ConnectionFactory cf, String name, List<InetSocketAddress> addrs)
352385
throws IOException {
353386
super(cf, name, addrs);
354387

@@ -369,7 +402,7 @@ public ArcusClient(ConnectionFactory cf, String name, List<InetSocketAddress> ad
369402
* @param addrs socket addresses for the memcached servers
370403
* @throws IOException if connections cannot be established
371404
*/
372-
public ArcusClient(ConnectionFactory cf, List<InetSocketAddress> addrs)
405+
protected ArcusClient(ConnectionFactory cf, List<InetSocketAddress> addrs)
373406
throws IOException {
374407
this(cf, DEFAULT_ARCUS_CLIENT_NAME + "-" + CLIENT_ID.getAndIncrement(), addrs);
375408
}

src/test/manual/net/spy/memcached/collection/BaseIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void connectionLost(SocketAddress sa) {
120120
};
121121
cfb.setInitialObservers(Collections.singleton(obs));
122122

123-
mc = new ArcusClient(cfb.build(), AddrUtil.getAddresses(ARCUS_HOST));
123+
mc = ArcusClient.createArcusClient(AddrUtil.getAddresses(ARCUS_HOST), cfb);
124124
latch.await();
125125
}
126126

0 commit comments

Comments
 (0)