Skip to content

Commit

Permalink
BOOKKEEPER-1001: Make LocalBookiesRegistry.isLocalBookie() public
Browse files Browse the repository at this point in the history
Author: Francesco Caliumi - Diennea <francesco.caliumi@diennea.com>

Reviewers: Enrico Olivelli <eolivelli@gmail.com>, Venkateswararao Jujjuri (JV) <None>, Sijie Guo <sijie@apache.org>

Closes #106 from caiok/BOOKKEEPER-1001
  • Loading branch information
caliuf authored and sijie committed Mar 23, 2017
1 parent 3d3340b commit 986110c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
Expand Up @@ -26,7 +26,7 @@
/**
* Local registry for embedded Bookies
*/
class LocalBookiesRegistry {
public class LocalBookiesRegistry {

private final static ConcurrentHashMap<BookieSocketAddress,Boolean> localBookiesRegistry
= new ConcurrentHashMap<>();
Expand All @@ -39,7 +39,7 @@ static void unregisterLocalBookieAddress(BookieSocketAddress address) {
localBookiesRegistry.remove(address);
}
}
static boolean isLocalBookie(BookieSocketAddress address) {
public static boolean isLocalBookie(BookieSocketAddress address) {
return localBookiesRegistry.containsKey(address);
}

Expand Down
@@ -0,0 +1,59 @@
/**
*
* 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.bookkeeper.test;

import org.apache.bookkeeper.client.BookKeeper;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.proto.BookieServer;
import org.apache.bookkeeper.proto.LocalBookiesRegistry;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
* Test the correctness and the availability outside of its package of LocalBookiesRegistryTest
*/
public class LocalBookiesRegistryTest extends BaseTestCase {

@Override
protected ServerConfiguration newServerConfiguration() throws Exception {
return super
.newServerConfiguration()
.setDisableServerSocketBind(true)
.setEnableLocalTransport(true);
}

BookKeeper.DigestType digestType;

public LocalBookiesRegistryTest(BookKeeper.DigestType digestType) {
super(3);
this.digestType = digestType;
}

@Test
public void testAccessibleLocalBookiesRegistry() throws Exception {
assertEquals(3,bs.size());
for (BookieServer bk : bs) {
assertTrue(LocalBookiesRegistry.isLocalBookie(bk.getLocalAddress()));
}
}
}

0 comments on commit 986110c

Please sign in to comment.