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
18 changes: 10 additions & 8 deletions common/src/main/java/org/apache/omid/NetworkUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NetworkUtils {

private static final Logger LOG = LoggerFactory.getLogger(NetworkUtils.class);
Expand All @@ -36,7 +37,7 @@ public class NetworkUtils {

public static String getDefaultNetworkInterface() {

try (DatagramSocket s=new DatagramSocket()) {
try (DatagramSocket s = new DatagramSocket()) {
s.connect(InetAddress.getByAddress(new byte[]{1,1,1,1}), 0);
return NetworkInterface.getByInetAddress(s.getLocalAddress()).getName();
} catch (Exception e) {
Expand All @@ -51,13 +52,14 @@ public static String getDefaultNetworkInterface() {
NetworkInterface nextElement = networkInterfaces.nextElement();
String name = nextElement.getDisplayName();
LOG.info("Iterating over network interfaces, found '{}'", name);
boolean hasInet = Collections.list(nextElement.getInetAddresses()).size() > 1; // Checking that inet exists, to avoid taking iBridge
// Checking that inet exists, to avoid taking iBridge
boolean hasInet = Collections.list(nextElement.getInetAddresses()).size() > 1;
if (hasInet && fallBackName == null) {
fallBackName = name;
}
if ((name.startsWith(MAC_TSO_NET_IFACE_PREFIX) && hasInet ) ||
name.startsWith(LINUX_TSO_NET_IFACE_PREFIX)) {
return name;
if ((name.startsWith(MAC_TSO_NET_IFACE_PREFIX) && hasInet )
|| name.startsWith(LINUX_TSO_NET_IFACE_PREFIX)) {
return name;
}
}
if (fallBackName != null) {
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/java/org/apache/omid/ReflectionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectionHelper {

static public <T> Object invokeParameterlessMethod(T theObject, String methodName)
public static <T> Object invokeParameterlessMethod(T theObject, String methodName)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

Method method = theObject.getClass().getDeclaredMethod(methodName, null);
Expand Down
6 changes: 4 additions & 2 deletions common/src/main/java/org/apache/omid/YAMLUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
import org.apache.phoenix.thirdparty.com.google.common.io.Resources;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
Expand Down Expand Up @@ -56,7 +57,8 @@ public void loadSettings(String resourcePath, Object bean) {
@SuppressWarnings("unchecked")
public Map loadSettings(String resourcePath, String defaultResourcePath) throws IOException {
Map defaultSetting = loadAsMap(defaultResourcePath);
Preconditions.checkState(defaultSetting.size() > 0, String.format("Failed to load file '%s' from classpath", defaultResourcePath));
Preconditions.checkState(defaultSetting.size() > 0,
String.format("Failed to load file '%s' from classpath", defaultResourcePath));
if (resourcePath != null) {
Map userSetting = loadAsMap(resourcePath);
defaultSetting.putAll(userSetting);
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/org/apache/omid/zk/ZKUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid.zk;

import org.apache.curator.RetryPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import org.testng.annotations.Test;
Expand All @@ -27,8 +28,8 @@ public static class TestClass {

private final int theNumber;

public TestClass(int aNumber) {
this.theNumber = aNumber;
public TestClass(int number) {
this.theNumber = number;
}

private int getTheNumber() {
Expand Down
5 changes: 3 additions & 2 deletions common/src/test/java/org/apache/omid/YAMLUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.omid;

import org.testng.Assert;
Expand All @@ -26,7 +27,7 @@
public class YAMLUtilsTest {

@Test(timeOut = 10_000)
public void testLoadDefaultSettings_setToBean() throws Exception {
public void testLoadDefaultSettings_setToBean() {
Map map = new HashMap();
new YAMLUtils().loadSettings("test.yml", "default-test.yml", map);
Assert.assertNotNull(map);
Expand All @@ -36,7 +37,7 @@ public void testLoadDefaultSettings_setToBean() throws Exception {
}

@Test(timeOut = 10_000)
public void testLoadDefaultSettings_setToBean2() throws Exception {
public void testLoadDefaultSettings_setToBean2() {
Map map = new HashMap();
new YAMLUtils().loadSettings("test.yml", map);
Assert.assertNotNull(map);
Expand Down