You are viewing a plain text version of this content. The canonical link for it is here.
Posted to distributedlog-dev@bookkeeper.apache.org by si...@apache.org on 2017/06/12 15:45:32 UTC
[25/30] incubator-distributedlog git commit: DL-205: Remove
StatusCode dependency on DLException
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestConsistentHashRoutingService.java
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestConsistentHashRoutingService.java b/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestConsistentHashRoutingService.java
deleted file mode 100644
index f44cddd..0000000
--- a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestConsistentHashRoutingService.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.distributedlog.client.routing;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import org.apache.distributedlog.client.resolver.DefaultRegionResolver;
-import org.apache.distributedlog.service.DLSocketAddress;
-import com.twitter.finagle.Address;
-import com.twitter.finagle.Addresses;
-import com.twitter.finagle.ChannelWriteException;
-import com.twitter.finagle.NoBrokersAvailableException;
-import com.twitter.finagle.stats.NullStatsReceiver;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import org.junit.Test;
-
-/**
- * Test Case for {@link ConsistentHashRoutingService}.
- */
-public class TestConsistentHashRoutingService {
-
- @Test(timeout = 60000)
- public void testBlackoutHost() throws Exception {
- TestName name = new TestName();
- RoutingService routingService = ConsistentHashRoutingService.newBuilder()
- .serverSet(new NameServerSet(name))
- .resolveFromName(true)
- .numReplicas(997)
- .blackoutSeconds(2)
- .build();
-
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", 3181);
- Address address = Addresses.newInetAddress(inetAddress);
- List<Address> addresses = new ArrayList<Address>(1);
- addresses.add(address);
- name.changeAddrs(addresses);
-
- routingService.startService();
-
- RoutingService.RoutingContext routingContext =
- RoutingService.RoutingContext.of(new DefaultRegionResolver());
-
- String streamName = "test-blackout-host";
- assertEquals(inetAddress, routingService.getHost(streamName, routingContext));
- routingService.removeHost(inetAddress, new ChannelWriteException(new IOException("test exception")));
- try {
- routingService.getHost(streamName, routingContext);
- fail("Should fail to get host since no brokers are available");
- } catch (NoBrokersAvailableException nbae) {
- // expected
- }
-
- TimeUnit.SECONDS.sleep(3);
- assertEquals(inetAddress, routingService.getHost(streamName, routingContext));
-
- routingService.stopService();
- }
-
- @Test(timeout = 60000)
- public void testPerformServerSetChangeOnName() throws Exception {
- TestName name = new TestName();
- ConsistentHashRoutingService routingService = (ConsistentHashRoutingService)
- ConsistentHashRoutingService.newBuilder()
- .serverSet(new NameServerSet(name))
- .resolveFromName(true)
- .numReplicas(997)
- .build();
-
- int basePort = 3180;
- int numHosts = 4;
- List<Address> addresses1 = Lists.newArrayListWithExpectedSize(4);
- List<Address> addresses2 = Lists.newArrayListWithExpectedSize(4);
- List<Address> addresses3 = Lists.newArrayListWithExpectedSize(4);
-
- // fill up the addresses1
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + i);
- Address address = Addresses.newInetAddress(inetAddress);
- addresses1.add(address);
- }
- // fill up the addresses2 - overlap with addresses1
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + 2 + i);
- Address address = Addresses.newInetAddress(inetAddress);
- addresses2.add(address);
- }
- // fill up the addresses3 - not overlap with addresses2
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + 10 + i);
- Address address = Addresses.newInetAddress(inetAddress);
- addresses3.add(address);
- }
-
- final List<SocketAddress> leftAddresses = Lists.newArrayList();
- final List<SocketAddress> joinAddresses = Lists.newArrayList();
-
- RoutingService.RoutingListener routingListener = new RoutingService.RoutingListener() {
- @Override
- public void onServerLeft(SocketAddress address) {
- synchronized (leftAddresses) {
- leftAddresses.add(address);
- leftAddresses.notifyAll();
- }
- }
-
- @Override
- public void onServerJoin(SocketAddress address) {
- synchronized (joinAddresses) {
- joinAddresses.add(address);
- joinAddresses.notifyAll();
- }
- }
- };
-
- routingService.registerListener(routingListener);
- name.changeAddrs(addresses1);
-
- routingService.startService();
-
- synchronized (joinAddresses) {
- while (joinAddresses.size() < numHosts) {
- joinAddresses.wait();
- }
- }
-
- // validate 4 nodes joined
- synchronized (joinAddresses) {
- assertEquals(numHosts, joinAddresses.size());
- }
- synchronized (leftAddresses) {
- assertEquals(0, leftAddresses.size());
- }
- assertEquals(numHosts, routingService.shardId2Address.size());
- assertEquals(numHosts, routingService.address2ShardId.size());
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
-
- // update addresses2 - 2 new hosts joined, 2 old hosts left
- name.changeAddrs(addresses2);
- synchronized (joinAddresses) {
- while (joinAddresses.size() < numHosts + 2) {
- joinAddresses.wait();
- }
- }
- synchronized (leftAddresses) {
- while (leftAddresses.size() < numHosts - 2) {
- leftAddresses.wait();
- }
- }
- assertEquals(numHosts, routingService.shardId2Address.size());
- assertEquals(numHosts, routingService.address2ShardId.size());
-
- // first 2 shards should leave
- for (int i = 0; i < 2; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + i);
- assertFalse(routingService.address2ShardId.containsKey(inetAddress));
- }
-
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + 2 + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
-
- // update addresses3 - 2 new hosts joined, 2 old hosts left
- name.changeAddrs(addresses3);
- synchronized (joinAddresses) {
- while (joinAddresses.size() < numHosts + 2 + numHosts) {
- joinAddresses.wait();
- }
- }
- synchronized (leftAddresses) {
- while (leftAddresses.size() < numHosts - 2 + numHosts) {
- leftAddresses.wait();
- }
- }
- assertEquals(numHosts, routingService.shardId2Address.size());
- assertEquals(numHosts, routingService.address2ShardId.size());
-
- // first 6 shards should leave
- for (int i = 0; i < 2 + numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + i);
- assertFalse(routingService.address2ShardId.containsKey(inetAddress));
- }
- // new 4 shards should exist
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + 10 + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
-
- }
-
- private static class TestServerSetWatcher implements ServerSetWatcher {
-
- final LinkedBlockingQueue<ImmutableSet<DLSocketAddress>> changeQueue =
- new LinkedBlockingQueue<ImmutableSet<DLSocketAddress>>();
- final CopyOnWriteArrayList<ServerSetMonitor> monitors =
- new CopyOnWriteArrayList<ServerSetMonitor>();
-
- @Override
- public void watch(ServerSetMonitor monitor) throws MonitorException {
- monitors.add(monitor);
- ImmutableSet<DLSocketAddress> change;
- while ((change = changeQueue.poll()) != null) {
- notifyChanges(change);
- }
- }
-
- void notifyChanges(ImmutableSet<DLSocketAddress> addresses) {
- if (monitors.isEmpty()) {
- changeQueue.add(addresses);
- } else {
- for (ServerSetMonitor monitor : monitors) {
- monitor.onChange(addresses);
- }
- }
- }
- }
-
- @Test(timeout = 60000)
- public void testPerformServerSetChangeOnServerSet() throws Exception {
- TestServerSetWatcher serverSetWatcher = new TestServerSetWatcher();
- ConsistentHashRoutingService routingService = new ConsistentHashRoutingService(
- serverSetWatcher, 997, Integer.MAX_VALUE, NullStatsReceiver.get());
-
- int basePort = 3180;
- int numHosts = 4;
- Set<DLSocketAddress> addresses1 = Sets.newConcurrentHashSet();
- Set<DLSocketAddress> addresses2 = Sets.newConcurrentHashSet();
- Set<DLSocketAddress> addresses3 = Sets.newConcurrentHashSet();
-
- // fill up the addresses1
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + i);
- DLSocketAddress dsa = new DLSocketAddress(i, inetAddress);
- addresses1.add(dsa);
- }
- // fill up the addresses2 - overlap with addresses1
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + numHosts + i);
- DLSocketAddress dsa = new DLSocketAddress(i + 2, inetAddress);
- addresses2.add(dsa);
- }
- // fill up the addresses3 - not overlap with addresses2
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + 10 + i);
- DLSocketAddress dsa = new DLSocketAddress(i, inetAddress);
- addresses3.add(dsa);
- }
-
- final List<SocketAddress> leftAddresses = Lists.newArrayList();
- final List<SocketAddress> joinAddresses = Lists.newArrayList();
-
- RoutingService.RoutingListener routingListener = new RoutingService.RoutingListener() {
- @Override
- public void onServerLeft(SocketAddress address) {
- synchronized (leftAddresses) {
- leftAddresses.add(address);
- leftAddresses.notifyAll();
- }
- }
-
- @Override
- public void onServerJoin(SocketAddress address) {
- synchronized (joinAddresses) {
- joinAddresses.add(address);
- joinAddresses.notifyAll();
- }
- }
- };
-
- routingService.registerListener(routingListener);
- serverSetWatcher.notifyChanges(ImmutableSet.copyOf(addresses1));
-
- routingService.startService();
-
- synchronized (joinAddresses) {
- while (joinAddresses.size() < numHosts) {
- joinAddresses.wait();
- }
- }
-
- // validate 4 nodes joined
- synchronized (joinAddresses) {
- assertEquals(numHosts, joinAddresses.size());
- }
- synchronized (leftAddresses) {
- assertEquals(0, leftAddresses.size());
- }
- assertEquals(numHosts, routingService.shardId2Address.size());
- assertEquals(numHosts, routingService.address2ShardId.size());
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- assertEquals(i, shardId);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
-
- // update addresses2 - 2 new hosts joined, 2 old hosts left
- serverSetWatcher.notifyChanges(ImmutableSet.copyOf(addresses2));
- synchronized (joinAddresses) {
- while (joinAddresses.size() < numHosts + 2) {
- joinAddresses.wait();
- }
- }
- synchronized (leftAddresses) {
- while (leftAddresses.size() < 2) {
- leftAddresses.wait();
- }
- }
-
- assertEquals(numHosts + 2, routingService.shardId2Address.size());
- assertEquals(numHosts + 2, routingService.address2ShardId.size());
- // first 2 shards should not leave
- for (int i = 0; i < 2; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- assertEquals(i, shardId);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + numHosts + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- assertEquals(i + 2, shardId);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
-
- // update addresses3
- serverSetWatcher.notifyChanges(ImmutableSet.copyOf(addresses3));
- synchronized (joinAddresses) {
- while (joinAddresses.size() < numHosts + 2 + numHosts) {
- joinAddresses.wait();
- }
- }
- synchronized (leftAddresses) {
- while (leftAddresses.size() < 2 + numHosts) {
- leftAddresses.wait();
- }
- }
- assertEquals(numHosts + 2, routingService.shardId2Address.size());
- assertEquals(numHosts + 2, routingService.address2ShardId.size());
-
- // first 4 shards should leave
- for (int i = 0; i < numHosts; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + 10 + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- assertEquals(i, shardId);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
- // the other 2 shards should be still there
- for (int i = 0; i < 2; i++) {
- InetSocketAddress inetAddress = new InetSocketAddress("127.0.0.1", basePort + numHosts + 2 + i);
- assertTrue(routingService.address2ShardId.containsKey(inetAddress));
- int shardId = routingService.address2ShardId.get(inetAddress);
- assertEquals(numHosts + i, shardId);
- SocketAddress sa = routingService.shardId2Address.get(shardId);
- assertNotNull(sa);
- assertEquals(inetAddress, sa);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestInetNameResolution.java
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestInetNameResolution.java b/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestInetNameResolution.java
deleted file mode 100644
index 59665b9..0000000
--- a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestInetNameResolution.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.distributedlog.client.routing;
-
-import com.google.common.collect.ImmutableSet;
-import com.twitter.common.net.pool.DynamicHostSet;
-import com.twitter.thrift.Endpoint;
-import com.twitter.thrift.ServiceInstance;
-import java.net.InetSocketAddress;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test Case for `inet` name resolution.
- */
-public class TestInetNameResolution {
-
- private static final Logger logger = LoggerFactory.getLogger(TestRoutingService.class);
-
- @Test(timeout = 10000)
- public void testInetNameResolution() throws Exception {
- String nameStr = "inet!127.0.0.1:3181";
- final CountDownLatch resolved = new CountDownLatch(1);
- final AtomicBoolean validationFailed = new AtomicBoolean(false);
-
- NameServerSet serverSet = new NameServerSet(nameStr);
- serverSet.watch(new DynamicHostSet.HostChangeMonitor<ServiceInstance>() {
- @Override
- public void onChange(ImmutableSet<ServiceInstance> hostSet) {
- if (hostSet.size() > 1) {
- logger.error("HostSet has more elements than expected {}", hostSet);
- validationFailed.set(true);
- resolved.countDown();
- } else if (hostSet.size() == 1) {
- ServiceInstance serviceInstance = hostSet.iterator().next();
- Endpoint endpoint = serviceInstance.getAdditionalEndpoints().get("thrift");
- InetSocketAddress address = new InetSocketAddress(endpoint.getHost(), endpoint.getPort());
- if (endpoint.getPort() != 3181) {
- logger.error("Port does not match the expected port {}", endpoint.getPort());
- validationFailed.set(true);
- } else if (!address.getAddress().getHostAddress().equals("127.0.0.1")) {
- logger.error("Host address does not match the expected address {}",
- address.getAddress().getHostAddress());
- validationFailed.set(true);
- }
- resolved.countDown();
- }
- }
- });
-
- resolved.await();
- Assert.assertEquals(false, validationFailed.get());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRegionsRoutingService.java
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRegionsRoutingService.java b/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRegionsRoutingService.java
deleted file mode 100644
index 151663e..0000000
--- a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRegionsRoutingService.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.distributedlog.client.routing;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import com.google.common.collect.Sets;
-import org.apache.distributedlog.client.resolver.DefaultRegionResolver;
-import org.apache.distributedlog.thrift.service.StatusCode;
-import com.twitter.finagle.NoBrokersAvailableException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.Test;
-
-/**
- * Test Case for {@link RegionsRoutingService}.
- */
-public class TestRegionsRoutingService {
-
- @Test(timeout = 60000)
- public void testRoutingListener() throws Exception {
- int numRoutingServices = 5;
- RoutingService.Builder[] routingServiceBuilders = new RoutingService.Builder[numRoutingServices];
- Set<SocketAddress> hosts = new HashSet<SocketAddress>();
- Map<SocketAddress, String> regionMap = new HashMap<SocketAddress, String>();
- for (int i = 0; i < numRoutingServices; i++) {
- String finagleNameStr = "inet!127.0.0.1:" + (3181 + i);
- routingServiceBuilders[i] = RoutingUtils.buildRoutingService(finagleNameStr);
- SocketAddress address = new InetSocketAddress("127.0.0.1", 3181 + i);
- hosts.add(address);
- regionMap.put(address, "region-" + i);
- }
-
- final CountDownLatch doneLatch = new CountDownLatch(numRoutingServices);
- final AtomicInteger numHostsLeft = new AtomicInteger(0);
- final Set<SocketAddress> jointHosts = new HashSet<SocketAddress>();
- RegionsRoutingService regionsRoutingService =
- RegionsRoutingService.newBuilder()
- .routingServiceBuilders(routingServiceBuilders)
- .resolver(new DefaultRegionResolver(regionMap))
- .build();
- regionsRoutingService.registerListener(new RoutingService.RoutingListener() {
- @Override
- public void onServerLeft(SocketAddress address) {
- numHostsLeft.incrementAndGet();
- }
-
- @Override
- public void onServerJoin(SocketAddress address) {
- jointHosts.add(address);
- doneLatch.countDown();
- }
- });
-
- regionsRoutingService.startService();
-
- doneLatch.await();
-
- assertEquals(numRoutingServices, jointHosts.size());
- assertEquals(0, numHostsLeft.get());
- assertTrue(Sets.difference(hosts, jointHosts).immutableCopy().isEmpty());
- }
-
- @Test(timeout = 60000)
- public void testGetHost() throws Exception {
- int numRoutingServices = 3;
- RoutingService.Builder[] routingServiceBuilders = new RoutingService.Builder[numRoutingServices];
- Map<SocketAddress, String> regionMap = new HashMap<SocketAddress, String>();
- for (int i = 0; i < numRoutingServices; i++) {
- String finagleNameStr = "inet!127.0.0.1:" + (3181 + i);
- routingServiceBuilders[i] = RoutingUtils.buildRoutingService(finagleNameStr);
- SocketAddress address = new InetSocketAddress("127.0.0.1", 3181 + i);
- regionMap.put(address, "region-" + i);
- }
-
- RegionsRoutingService regionsRoutingService =
- RegionsRoutingService.newBuilder()
- .resolver(new DefaultRegionResolver(regionMap))
- .routingServiceBuilders(routingServiceBuilders)
- .build();
- regionsRoutingService.startService();
-
- RoutingService.RoutingContext routingContext =
- RoutingService.RoutingContext.of(new DefaultRegionResolver())
- .addTriedHost(new InetSocketAddress("127.0.0.1", 3183), StatusCode.WRITE_EXCEPTION);
- assertEquals(new InetSocketAddress("127.0.0.1", 3181),
- regionsRoutingService.getHost("any", routingContext));
-
- routingContext =
- RoutingService.RoutingContext.of(new DefaultRegionResolver())
- .addTriedHost(new InetSocketAddress("127.0.0.1", 3181), StatusCode.WRITE_EXCEPTION);
- assertEquals(new InetSocketAddress("127.0.0.1", 3182),
- regionsRoutingService.getHost("any", routingContext));
-
- // add 3182 to routing context as tried host
- routingContext.addTriedHost(new InetSocketAddress("127.0.0.1", 3182), StatusCode.WRITE_EXCEPTION);
- assertEquals(new InetSocketAddress("127.0.0.1", 3183),
- regionsRoutingService.getHost("any", routingContext));
-
- // add 3183 to routing context as tried host
- routingContext.addTriedHost(new InetSocketAddress("127.0.0.1", 3183), StatusCode.WRITE_EXCEPTION);
- try {
- regionsRoutingService.getHost("any", routingContext);
- fail("Should fail to get host since all regions are tried.");
- } catch (NoBrokersAvailableException nbae) {
- // expected
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRoutingService.java
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRoutingService.java b/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRoutingService.java
deleted file mode 100644
index d2d61a9..0000000
--- a/distributedlog-client/src/test/java/org/apache/distributedlog/client/routing/TestRoutingService.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.distributedlog.client.routing;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.distributedlog.client.resolver.DefaultRegionResolver;
-import com.twitter.finagle.Address;
-import com.twitter.finagle.Addresses;
-import com.twitter.finagle.addr.WeightedAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test Case for {@link RoutingService}.
- */
-@RunWith(Parameterized.class)
-public class TestRoutingService {
-
- static final Logger LOG = LoggerFactory.getLogger(TestRoutingService.class);
-
- @Parameterized.Parameters
- public static Collection<Object[]> configs() {
- ArrayList<Object[]> list = new ArrayList<Object[]>();
- for (int i = 0; i <= 1; i++) {
- for (int j = 0; j <= 1; j++) {
- for (int k = 0; k <= 1; k++) {
- list.add(new Boolean[] {i == 1, j == 1, k == 1});
- }
- }
- }
- return list;
- }
-
- private final boolean consistentHash;
- private final boolean weightedAddresses;
- private final boolean asyncResolution;
-
- public TestRoutingService(boolean consistentHash, boolean weightedAddresses, boolean asyncResolution) {
- this.consistentHash = consistentHash;
- this.weightedAddresses = weightedAddresses;
- this.asyncResolution = asyncResolution;
- }
-
- private List<Address> getAddresses(boolean weightedAddresses) {
- ArrayList<Address> addresses = new ArrayList<Address>();
- addresses.add(Addresses.newInetAddress(new InetSocketAddress("127.0.0.1", 3181)));
- addresses.add(Addresses.newInetAddress(new InetSocketAddress("127.0.0.2", 3181)));
- addresses.add(Addresses.newInetAddress(new InetSocketAddress("127.0.0.3", 3181)));
- addresses.add(Addresses.newInetAddress(new InetSocketAddress("127.0.0.4", 3181)));
- addresses.add(Addresses.newInetAddress(new InetSocketAddress("127.0.0.5", 3181)));
- addresses.add(Addresses.newInetAddress(new InetSocketAddress("127.0.0.6", 3181)));
- addresses.add(Addresses.newInetAddress(new InetSocketAddress("127.0.0.7", 3181)));
-
- if (weightedAddresses) {
- ArrayList<Address> wAddresses = new ArrayList<Address>();
- for (Address address: addresses) {
- wAddresses.add(WeightedAddress.apply(address, 1.0));
- }
- return wAddresses;
- } else {
- return addresses;
- }
- }
-
- private void testRoutingServiceHelper(boolean consistentHash,
- boolean weightedAddresses,
- boolean asyncResolution)
- throws Exception {
- ExecutorService executorService = null;
- final List<Address> addresses = getAddresses(weightedAddresses);
- final TestName name = new TestName();
- RoutingService routingService;
- if (consistentHash) {
- routingService = ConsistentHashRoutingService.newBuilder()
- .serverSet(new NameServerSet(name))
- .resolveFromName(true)
- .numReplicas(997)
- .build();
- } else {
- routingService = ServerSetRoutingService.newServerSetRoutingServiceBuilder()
- .serverSetWatcher(new TwitterServerSetWatcher(new NameServerSet(name), true)).build();
- }
-
- if (asyncResolution) {
- executorService = Executors.newSingleThreadExecutor();
- executorService.submit(new Runnable() {
- @Override
- public void run() {
- name.changeAddrs(addresses);
- }
- });
- } else {
- name.changeAddrs(addresses);
- }
- routingService.startService();
-
- HashSet<SocketAddress> mapping = new HashSet<SocketAddress>();
-
- for (int i = 0; i < 1000; i++) {
- for (int j = 0; j < 5; j++) {
- String stream = "TestStream-" + i + "-" + j;
- mapping.add(routingService.getHost(stream,
- RoutingService.RoutingContext.of(new DefaultRegionResolver())));
- }
- }
-
- assertEquals(mapping.size(), addresses.size());
-
- if (null != executorService) {
- executorService.shutdown();
- }
-
- }
-
- @Test(timeout = 5000)
- public void testRoutingService() throws Exception {
- testRoutingServiceHelper(this.consistentHash, this.weightedAddresses, this.asyncResolution);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-client/src/test/java/org/apache/distributedlog/client/speculative/TestDefaultSpeculativeRequestExecutionPolicy.java
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/test/java/org/apache/distributedlog/client/speculative/TestDefaultSpeculativeRequestExecutionPolicy.java b/distributedlog-client/src/test/java/org/apache/distributedlog/client/speculative/TestDefaultSpeculativeRequestExecutionPolicy.java
deleted file mode 100644
index ab0cb58..0000000
--- a/distributedlog-client/src/test/java/org/apache/distributedlog/client/speculative/TestDefaultSpeculativeRequestExecutionPolicy.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.distributedlog.client.speculative;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
-import com.twitter.util.CountDownLatch;
-import com.twitter.util.Future;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * Test {@link TestDefaultSpeculativeRequestExecutionPolicy}.
- */
-public class TestDefaultSpeculativeRequestExecutionPolicy {
-
- @Test(timeout = 20000, expected = IllegalArgumentException.class)
- public void testInvalidBackoffMultiplier() throws Exception {
- new DefaultSpeculativeRequestExecutionPolicy(100, 200, -1);
- }
-
- @Test(timeout = 20000, expected = IllegalArgumentException.class)
- public void testInvalidMaxSpeculativeTimeout() throws Exception {
- new DefaultSpeculativeRequestExecutionPolicy(100, Integer.MAX_VALUE, 2);
- }
-
- @Test(timeout = 20000)
- public void testSpeculativeRequests() throws Exception {
- DefaultSpeculativeRequestExecutionPolicy policy =
- new DefaultSpeculativeRequestExecutionPolicy(10, 10000, 2);
- SpeculativeRequestExecutor executor = mock(SpeculativeRequestExecutor.class);
-
- final AtomicInteger callCount = new AtomicInteger(0);
- final CountDownLatch latch = new CountDownLatch(3);
-
- Mockito.doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- try {
- return Future.value(callCount.incrementAndGet() < 3);
- } finally {
- latch.countDown();
- }
- }
- }).when(executor).issueSpeculativeRequest();
-
- ScheduledExecutorService executorService =
- Executors.newSingleThreadScheduledExecutor();
- policy.initiateSpeculativeRequest(executorService, executor);
-
- latch.await();
-
- assertEquals(40, policy.getNextSpeculativeRequestTimeout());
- }
-
- @Test(timeout = 20000)
- public void testSpeculativeRequestsWithMaxTimeout() throws Exception {
- DefaultSpeculativeRequestExecutionPolicy policy =
- new DefaultSpeculativeRequestExecutionPolicy(10, 15, 2);
- SpeculativeRequestExecutor executor = mock(SpeculativeRequestExecutor.class);
-
- final AtomicInteger callCount = new AtomicInteger(0);
- final CountDownLatch latch = new CountDownLatch(3);
-
- Mockito.doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- try {
- return Future.value(callCount.incrementAndGet() < 3);
- } finally {
- latch.countDown();
- }
- }
- }).when(executor).issueSpeculativeRequest();
-
- ScheduledExecutorService executorService =
- Executors.newSingleThreadScheduledExecutor();
- policy.initiateSpeculativeRequest(executorService, executor);
-
- latch.await();
-
- assertEquals(15, policy.getNextSpeculativeRequestTimeout());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-client/src/test/java/org/apache/distributedlog/service/TestDistributedLogClientBuilder.java
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/test/java/org/apache/distributedlog/service/TestDistributedLogClientBuilder.java b/distributedlog-client/src/test/java/org/apache/distributedlog/service/TestDistributedLogClientBuilder.java
deleted file mode 100644
index d2df9a5..0000000
--- a/distributedlog-client/src/test/java/org/apache/distributedlog/service/TestDistributedLogClientBuilder.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.distributedlog.service;
-
-import static org.junit.Assert.assertFalse;
-
-import com.twitter.finagle.builder.ClientBuilder;
-import com.twitter.finagle.thrift.ClientId$;
-import com.twitter.util.Duration;
-import org.junit.Test;
-
-/**
- * Test Case of {@link org.apache.distributedlog.service.DistributedLogClientBuilder}.
- */
-public class TestDistributedLogClientBuilder {
-
- @Test(timeout = 60000)
- public void testBuildClientsFromSameBuilder() throws Exception {
- DistributedLogClientBuilder builder = DistributedLogClientBuilder.newBuilder()
- .name("build-clients-from-same-builder")
- .clientId(ClientId$.MODULE$.apply("test-builder"))
- .finagleNameStr("inet!127.0.0.1:7001")
- .streamNameRegex(".*")
- .handshakeWithClientInfo(true)
- .clientBuilder(ClientBuilder.get()
- .hostConnectionLimit(1)
- .connectTimeout(Duration.fromSeconds(1))
- .tcpConnectTimeout(Duration.fromSeconds(1))
- .requestTimeout(Duration.fromSeconds(10)));
- DistributedLogClient client1 = builder.build();
- DistributedLogClient client2 = builder.build();
- assertFalse(client1 == client2);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-client/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/distributedlog-client/src/test/resources/log4j.properties b/distributedlog-client/src/test/resources/log4j.properties
deleted file mode 100644
index 3e51059..0000000
--- a/distributedlog-client/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,51 +0,0 @@
-#/**
-# * Licensed to the Apache Software Foundation (ASF) under one
-# * or more contributor license agreements. See the NOTICE file
-# * distributed with this work for additional information
-# * regarding copyright ownership. The ASF licenses this file
-# * to you 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.
-# */
-
-#
-# DisributedLog Logging Configuration
-#
-
-# Example with rolling log file
-log4j.rootLogger=INFO, CONSOLE
-
-#disable zookeeper logging
-log4j.logger.org.apache.zookeeper=OFF
-#Set the bookkeeper level to warning
-log4j.logger.org.apache.bookkeeper=INFO
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=INFO
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n
-
-# Add ROLLINGFILE to rootLogger to get log file output
-# Log DEBUG level and above messages to a log file
-#log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender
-#log4j.appender.ROLLINGFILE.Threshold=INFO
-#log4j.appender.ROLLINGFILE.File=distributedlog.log
-#log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
-#log4j.appender.ROLLINGFILE.DatePattern='.'yyyy-MM-dd-HH-mm
-#log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n
-
-log4j.appender.R=org.apache.log4j.RollingFileAppender
-log4j.appender.R.Threshold=TRACE
-log4j.appender.R.File=target/error.log
-log4j.appender.R.MaxFileSize=200MB
-log4j.appender.R.MaxBackupIndex=7
-log4j.appender.R.layout=org.apache.log4j.PatternLayout
-log4j.appender.R.layout.ConversionPattern=%d{ISO8601} - %-5p - [%t:%C{1}@%L] - %m%n
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-core/src/main/java/org/apache/distributedlog/exceptions/ZKException.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/org/apache/distributedlog/exceptions/ZKException.java b/distributedlog-core/src/main/java/org/apache/distributedlog/exceptions/ZKException.java
index b9e9d12..5eab707 100644
--- a/distributedlog-core/src/main/java/org/apache/distributedlog/exceptions/ZKException.java
+++ b/distributedlog-core/src/main/java/org/apache/distributedlog/exceptions/ZKException.java
@@ -17,7 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.Code;
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/pom.xml
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/pom.xml b/distributedlog-protocol/pom.xml
index 8a9cb22..a483444 100644
--- a/distributedlog-protocol/pom.xml
+++ b/distributedlog-protocol/pom.xml
@@ -37,26 +37,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.apache.thrift</groupId>
- <artifactId>libthrift</artifactId>
- <version>${libthrift.version}</version>
- </dependency>
- <dependency>
- <groupId>com.twitter</groupId>
- <artifactId>scrooge-core_2.11</artifactId>
- <version>${scrooge.version}</version>
- </dependency>
- <dependency>
- <groupId>com.twitter</groupId>
- <artifactId>finagle-core_2.11</artifactId>
- <version>${finagle.version}</version>
- </dependency>
- <dependency>
- <groupId>com.twitter</groupId>
- <artifactId>finagle-thrift_2.11</artifactId>
- <version>${finagle.version}</version>
- </dependency>
- <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
@@ -67,6 +47,11 @@
<version>${commons-codec.version}</version>
</dependency>
<dependency>
+ <groupId>com.twitter</groupId>
+ <artifactId>finagle-core_2.11</artifactId>
+ <version>${finagle.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
@@ -86,26 +71,6 @@
<build>
<plugins>
<plugin>
- <groupId>com.twitter</groupId>
- <artifactId>scrooge-maven-plugin</artifactId>
- <version>${scrooge-maven-plugin.version}</version>
- <configuration>
- <language>java</language>
- <thriftOpts>
- <thriftOpt>--finagle</thriftOpt>
- </thriftOpts>
- </configuration>
- <executions>
- <execution>
- <id>thrift-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyClosedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyClosedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyClosedException.java
index ecb9180..258ff05 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyClosedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyClosedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Thrown when any distributedlog resources have already been closed.
*
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyTruncatedTransactionException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyTruncatedTransactionException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyTruncatedTransactionException.java
index 9f8d5bc..29903ac 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyTruncatedTransactionException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/AlreadyTruncatedTransactionException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Thrown when the transaction Id specified in the API is in the range that has already been truncated.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/BKTransmitException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/BKTransmitException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/BKTransmitException.java
index 7d0a5b3..33f4a04 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/BKTransmitException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/BKTransmitException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Thrown when the send to bookkeeper fails.
*
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ChecksumFailedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ChecksumFailedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ChecksumFailedException.java
index 36c7bd9..4210d66 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ChecksumFailedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ChecksumFailedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception thrown when checksum failures occurred.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLClientClosedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLClientClosedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLClientClosedException.java
index a5e4faa..bb7c2db 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLClientClosedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLClientClosedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exceptions thrown when a distributedlog client is closed.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLException.java
index e974d46..928895d 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.ResponseHeader;
-import org.apache.distributedlog.thrift.service.StatusCode;
import java.io.IOException;
/**
@@ -26,24 +24,24 @@ import java.io.IOException;
*/
public class DLException extends IOException {
private static final long serialVersionUID = -4485775468586114393L;
- protected final StatusCode code;
+ protected final int code;
- protected DLException(StatusCode code) {
+ public DLException(int code) {
super();
this.code = code;
}
- protected DLException(StatusCode code, String msg) {
+ public DLException(int code, String msg) {
super(msg);
this.code = code;
}
- protected DLException(StatusCode code, Throwable t) {
+ public DLException(int code, Throwable t) {
super(t);
this.code = code;
}
- protected DLException(StatusCode code, String msg, Throwable t) {
+ public DLException(int code, String msg, Throwable t) {
super(msg, t);
this.code = code;
}
@@ -53,29 +51,8 @@ public class DLException extends IOException {
*
* @return status code representing the exception.
*/
- public StatusCode getCode() {
+ public int getCode() {
return code;
}
- public static DLException of(ResponseHeader response) {
- String errMsg;
- switch (response.getCode()) {
- case FOUND:
- if (response.isSetErrMsg()) {
- errMsg = response.getErrMsg();
- } else {
- errMsg = "Request is redirected to " + response.getLocation();
- }
- return new OwnershipAcquireFailedException(errMsg, response.getLocation());
- case SUCCESS:
- throw new IllegalArgumentException("Can't instantiate an exception for success response.");
- default:
- if (response.isSetErrMsg()) {
- errMsg = response.getErrMsg();
- } else {
- errMsg = response.getCode().name();
- }
- return new DLException(response.getCode(), errMsg);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLIllegalStateException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLIllegalStateException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLIllegalStateException.java
index 7aa8c39..8dc4116 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLIllegalStateException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLIllegalStateException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Signals that a method has been invoked at an illegal or inappropriate time.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLInterruptedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLInterruptedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLInterruptedException.java
index 6eaf8ac..7b4d5be 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLInterruptedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/DLInterruptedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* An interrupted exception wrapper indicates dl operations are interrupted.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfLogSegmentException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfLogSegmentException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfLogSegmentException.java
index 356dde8..5c12995 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfLogSegmentException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfLogSegmentException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception thrown when reach end of the log segment.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfStreamException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfStreamException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfStreamException.java
index 4b8a931..cc2c79f 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfStreamException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/EndOfStreamException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception thrown when a reader reaches end of a sealed log stream.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/FlushException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/FlushException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/FlushException.java
index 7225970..b471778 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/FlushException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/FlushException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception indicates that errors occurred on flushing data.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InternalServerException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InternalServerException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InternalServerException.java
index 9032c2b..ff6338a 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InternalServerException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InternalServerException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception indicates that there is an internal error at distributedlog service side.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidEnvelopedEntryException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidEnvelopedEntryException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidEnvelopedEntryException.java
index d46d14e..b52af61 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidEnvelopedEntryException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidEnvelopedEntryException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception thrown when encounter invalid enveloped entry.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidStreamNameException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidStreamNameException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidStreamNameException.java
index 29e2663..ca6f4db 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidStreamNameException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/InvalidStreamNameException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when encountered invalid log stream.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LockingException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LockingException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LockingException.java
index 63f6b0f..55bd88f 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LockingException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LockingException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception when a log writer attempts to acquire a lock to write data to the stream.
*/
@@ -34,11 +32,11 @@ public class LockingException extends DLException {
this(StatusCode.LOCKING_EXCEPTION, lockPath, message, cause);
}
- protected LockingException(StatusCode code, String lockPath, String message) {
+ protected LockingException(int code, String lockPath, String message) {
super(code, String.format("LockPath - %s: %s", lockPath, message));
}
- protected LockingException(StatusCode code, String lockPath, String message, Throwable cause) {
+ protected LockingException(int code, String lockPath, String message, Throwable cause) {
super(code, String.format("LockPath - %s: %s", lockPath, message), cause);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogEmptyException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogEmptyException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogEmptyException.java
index ba3545d..0326a9a 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogEmptyException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogEmptyException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exceptions are thrown when attempt to read a log stream that doesn't have any records.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogExistsException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogExistsException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogExistsException.java
index 3ecb80f..cb2bc65 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogExistsException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogExistsException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception thrown on creating a log stream but the log stream already exists.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogNotFoundException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogNotFoundException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogNotFoundException.java
index 3795c5a..9ac14ba 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogNotFoundException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogNotFoundException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when a reader attempts to read a log stream that doesn't exist.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogReadException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogReadException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogReadException.java
index 91cf5c9..d2ca399 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogReadException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogReadException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Thrown when there's a failure to read an edit log op from disk when loading
* edits.
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogRecordTooLongException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogRecordTooLongException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogRecordTooLongException.java
index 2cb9085..dd1d66d 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogRecordTooLongException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogRecordTooLongException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when attempting to write a record whose size is too larger.
*
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentIsTruncatedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentIsTruncatedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentIsTruncatedException.java
index ac2ebda..3364940 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentIsTruncatedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentIsTruncatedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when reading data from a truncated log segment.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentNotFoundException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentNotFoundException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentNotFoundException.java
index 5245cdc..7fad552 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentNotFoundException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/LogSegmentNotFoundException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception on log segment not found.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/MetadataException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/MetadataException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/MetadataException.java
index 6dba778..559972b 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/MetadataException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/MetadataException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when encountering metadata errors.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/NotYetImplementedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/NotYetImplementedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/NotYetImplementedException.java
index eb709de..75eaa52 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/NotYetImplementedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/NotYetImplementedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when a method is not implemented yet.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OverCapacityException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OverCapacityException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OverCapacityException.java
index 6dc4767..4247874 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OverCapacityException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OverCapacityException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when the system is over capacity.
*
@@ -33,7 +31,7 @@ public class OverCapacityException extends DLException {
super(StatusCode.OVER_CAPACITY, message);
}
- public OverCapacityException(StatusCode code, String message) {
+ public OverCapacityException(int code, String message) {
super(code, message);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OwnershipAcquireFailedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OwnershipAcquireFailedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OwnershipAcquireFailedException.java
index af85e79..b077f5e 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OwnershipAcquireFailedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/OwnershipAcquireFailedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when a log writer attempt to acquire a lock.
*
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ReadCancelledException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ReadCancelledException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ReadCancelledException.java
index ac0508a..b179ce6 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ReadCancelledException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ReadCancelledException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Signals that a read request has been cancelled.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RegionUnavailableException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RegionUnavailableException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RegionUnavailableException.java
index 7a4b225..745ae6b 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RegionUnavailableException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RegionUnavailableException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception indicates that the service is not available in one region.
*
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RequestDeniedException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RequestDeniedException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RequestDeniedException.java
index ab730f3..e26f6db 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RequestDeniedException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RequestDeniedException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Signals that a request has been denied at the server.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RetryableReadException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RetryableReadException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RetryableReadException.java
index 10a1e53..1ed506f 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RetryableReadException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/RetryableReadException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Signals that a read request can be retried..
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ServiceUnavailableException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ServiceUnavailableException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ServiceUnavailableException.java
index ca266c2..5ab7f03 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ServiceUnavailableException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/ServiceUnavailableException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception indicates that the service is unavailable at the server side.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StatusCode.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StatusCode.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StatusCode.java
new file mode 100644
index 0000000..6dbb931
--- /dev/null
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StatusCode.java
@@ -0,0 +1,122 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.distributedlog.exceptions;
+
+/**
+ * Exception Status Code.
+ */
+public interface StatusCode {
+
+ /* 2xx: action requested by the client was received, understood, accepted and processed successfully. */
+
+ /* standard response for successful requests. */
+ int SUCCESS = 200;
+
+ /* 3xx: client must take additional action to complete the request. */
+
+ /* client closed. */
+ int CLIENT_CLOSED = 301;
+ /* found the stream in a different server, a redirection is required by client. */
+ int FOUND = 302;
+
+ /* 4xx: client seems to have erred. */
+
+ /* request is denied for some reason */
+ int REQUEST_DENIED = 403;
+ /* request record too large */
+ int TOO_LARGE_RECORD = 413;
+
+ /* 5xx: server failed to fulfill an apparently valid request. */
+
+ /* Generic error message, given when no more specific message is suitable. */
+ int INTERNAL_SERVER_ERROR = 500;
+ /* Not implemented */
+ int NOT_IMPLEMENTED = 501;
+ /* Already Closed Exception */
+ int ALREADY_CLOSED = 502;
+ /* Service is currently unavailable (because it is overloaded or down for maintenance). */
+ int SERVICE_UNAVAILABLE = 503;
+ /* Locking exception */
+ int LOCKING_EXCEPTION = 504;
+ /* ZooKeeper Errors */
+ int ZOOKEEPER_ERROR = 505;
+ /* Metadata exception */
+ int METADATA_EXCEPTION = 506;
+ /* BK Transmit Error */
+ int BK_TRANSMIT_ERROR = 507;
+ /* Flush timeout */
+ int FLUSH_TIMEOUT = 508;
+ /* Log empty */
+ int LOG_EMPTY = 509;
+ /* Log not found */
+ int LOG_NOT_FOUND = 510;
+ /* Truncated Transactions */
+ int TRUNCATED_TRANSACTION = 511;
+ /* End of Stream */
+ int END_OF_STREAM = 512;
+ /* Transaction Id Out of Order */
+ int TRANSACTION_OUT_OF_ORDER = 513;
+ /* Write exception */
+ int WRITE_EXCEPTION = 514;
+ /* Stream Unavailable */
+ int STREAM_UNAVAILABLE = 515;
+ /* Write cancelled exception */
+ int WRITE_CANCELLED_EXCEPTION = 516;
+ /* over-capacity/backpressure */
+ int OVER_CAPACITY = 517;
+
+ /** stream exists but is not ready (recovering etc.).
+ the difference between NOT_READY and UNAVAILABLE is that UNAVAILABLE
+ indicates the stream is no longer owned by the proxy and we should
+ redirect. NOT_READY indicates the stream exist at the proxy but isn't
+ eady for writes. */
+ int STREAM_NOT_READY = 518;
+ /* Region Unavailable */
+ int REGION_UNAVAILABLE = 519;
+ /* Invalid Enveloped Entry */
+ int INVALID_ENVELOPED_ENTRY = 520;
+ /* Unsupported metadata version */
+ int UNSUPPORTED_METADATA_VERSION = 521;
+ /* Log Already Exists */
+ int LOG_EXISTS = 522;
+ /* Checksum failed on the request */
+ int CHECKSUM_FAILED = 523;
+ /* Overcapacity: too many streams */
+ int TOO_MANY_STREAMS = 524;
+ /* Log Segment Not Found */
+ int LOG_SEGMENT_NOT_FOUND = 525;
+ /* End of Log Segment */
+ int END_OF_LOG_SEGMENT = 526;
+ /* Log Segment Is Truncated */
+ int LOG_SEGMENT_IS_TRUNCATED = 527;
+
+ /* 6xx: unexpected */
+
+ int UNEXPECTED = 600;
+ int INTERRUPTED = 601;
+ int INVALID_STREAM_NAME = 602;
+ int ILLEGAL_STATE = 603;
+
+ /* 10xx: reader exceptions */
+
+ int RETRYABLE_READ = 1000;
+ int LOG_READ_ERROR = 1001;
+ /* Read cancelled exception */
+ int READ_CANCELLED_EXCEPTION = 1002;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamNotReadyException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamNotReadyException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamNotReadyException.java
index ded9da1..a58a80f 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamNotReadyException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamNotReadyException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception is thrown when a log stream is not ready on server side for serving the write requests.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamUnavailableException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamUnavailableException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamUnavailableException.java
index fd0910e..ecba754 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamUnavailableException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/StreamUnavailableException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Exception thrown when a stream is not available for serving traffic.
*/
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/c44e0278/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/TooManyStreamsException.java
----------------------------------------------------------------------
diff --git a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/TooManyStreamsException.java b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/TooManyStreamsException.java
index 17e2e38..cc948d9 100644
--- a/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/TooManyStreamsException.java
+++ b/distributedlog-protocol/src/main/java/org/apache/distributedlog/exceptions/TooManyStreamsException.java
@@ -17,8 +17,6 @@
*/
package org.apache.distributedlog.exceptions;
-import org.apache.distributedlog.thrift.service.StatusCode;
-
/**
* Signals that a server has been serving too many streams.
*/