Skip to content

Commit

Permalink
GridUtils -> IgniteUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakov Zhdanov committed Jan 29, 2015
1 parent d6a720f commit fc768b8
Show file tree
Hide file tree
Showing 32 changed files with 93 additions and 96 deletions.
Expand Up @@ -338,8 +338,8 @@ public void setAwsCredentials(AWSCredentials cred) {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void spiStop() throws IgniteSpiException { @Override public void spiStop() throws IgniteSpiException {
if (timeoutWrk != null) { if (timeoutWrk != null) {
GridUtils.interrupt(timeoutWrk); IgniteUtils.interrupt(timeoutWrk);
GridUtils.join(timeoutWrk, log); IgniteUtils.join(timeoutWrk, log);
} }


unregisterMBean(); unregisterMBean();
Expand Down
Expand Up @@ -158,7 +158,7 @@ private File uncommentProperties(URL url) throws IOException {
while (it.hasNext()) while (it.hasNext())
lines.add(it.nextLine().replace("#gg.client.", "gg.client.")); lines.add(it.nextLine().replace("#gg.client.", "gg.client."));


GridUtils.closeQuiet(in); IgniteUtils.closeQuiet(in);


File tmp = File.createTempFile(UUID.randomUUID().toString(), "properties"); File tmp = File.createTempFile(UUID.randomUUID().toString(), "properties");


Expand Down Expand Up @@ -188,7 +188,7 @@ private Properties loadProperties(int expLoaded, URL url) throws IOException {


assertEquals(expLoaded, props.size()); assertEquals(expLoaded, props.size());


GridUtils.closeQuiet(in); IgniteUtils.closeQuiet(in);


return props; return props;
} }
Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


import static org.apache.ignite.internal.util.GridUtils.*; import static org.apache.ignite.internal.util.IgniteUtils.*;


/** /**
* General grid exception. This exception is used to indicate any error condition * General grid exception. This exception is used to indicate any error condition
Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


import static org.apache.ignite.internal.util.GridUtils.*; import static org.apache.ignite.internal.util.IgniteUtils.*;


/** /**
* General grid exception. This exception is used to indicate any error condition * General grid exception. This exception is used to indicate any error condition
Expand Down
Expand Up @@ -485,7 +485,7 @@ public void addDeploymentContext(GridDeploymentInfo info) {
allParticipants.put(nodeId, ldrVer); allParticipants.put(nodeId, ldrVer);


if (added == null) if (added == null)
added = GridUtils.newHashMap(participants.size()); added = IgniteUtils.newHashMap(participants.size());


added.put(nodeId, ldrVer); added.put(nodeId, ldrVer);
} }
Expand Down
Expand Up @@ -539,7 +539,7 @@ public boolean matches(GridCacheVersion ver, UUID nodeId, long threadId) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException { @Override public void writeExternal(ObjectOutput out) throws IOException {
GridUtils.writeUuid(out, nodeId); IgniteUtils.writeUuid(out, nodeId);


CU.writeVersion(out, ver); CU.writeVersion(out, ver);


Expand All @@ -551,7 +551,7 @@ public boolean matches(GridCacheVersion ver, UUID nodeId, long threadId) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
nodeId = GridUtils.readUuid(in); nodeId = IgniteUtils.readUuid(in);


ver = CU.readVersion(in); ver = CU.readVersion(in);


Expand Down
Expand Up @@ -80,7 +80,7 @@
* Collection of utility methods used throughout the system. * Collection of utility methods used throughout the system.
*/ */
@SuppressWarnings({"UnusedReturnValue", "UnnecessaryFullyQualifiedName"}) @SuppressWarnings({"UnusedReturnValue", "UnnecessaryFullyQualifiedName"})
public abstract class GridUtils { public abstract class IgniteUtils {
/** Unsafe. */ /** Unsafe. */
private static final Unsafe UNSAFE = GridUnsafe.unsafe(); private static final Unsafe UNSAFE = GridUnsafe.unsafe();


Expand Down Expand Up @@ -233,8 +233,8 @@ public abstract class GridUtils {
private static String jvmImplName; private static String jvmImplName;


/** JMX domain as 'xxx.gridgain'. */ /** JMX domain as 'xxx.gridgain'. */
public static final String JMX_DOMAIN = GridUtils.class.getName().substring(0, GridUtils.class.getName(). public static final String JMX_DOMAIN = IgniteUtils.class.getName().substring(0, IgniteUtils.class.getName().
indexOf('.', GridUtils.class.getName().indexOf('.') + 1)); indexOf('.', IgniteUtils.class.getName().indexOf('.') + 1));


/** Network packet header. */ /** Network packet header. */
public static final byte[] GG_HEADER = U.intToBytes(0x00004747); public static final byte[] GG_HEADER = U.intToBytes(0x00004747);
Expand Down Expand Up @@ -271,7 +271,7 @@ public abstract class GridUtils {
private static final Map<Class<?>, Class<?>> boxedClsMap = new HashMap<>(16, .5f); private static final Map<Class<?>, Class<?>> boxedClsMap = new HashMap<>(16, .5f);


/** Class loader used to load GridGain. */ /** Class loader used to load GridGain. */
private static final ClassLoader gridClassLoader = GridUtils.class.getClassLoader(); private static final ClassLoader gridClassLoader = IgniteUtils.class.getClassLoader();


/** MAC OS invalid argument socket error message. */ /** MAC OS invalid argument socket error message. */
public static final String MAC_INVALID_ARG_MSG = "On MAC OS you may have too many file descriptors open " + public static final String MAC_INVALID_ARG_MSG = "On MAC OS you may have too many file descriptors open " +
Expand Down Expand Up @@ -383,19 +383,19 @@ else if (archStr.contains("sparc"))
osJdkStr = osLow + ", " + jdkStr; osJdkStr = osLow + ", " + jdkStr;


// Copy auto variables to static ones. // Copy auto variables to static ones.
GridUtils.osName = osName; IgniteUtils.osName = osName;
GridUtils.jdkName = jdkName; IgniteUtils.jdkName = jdkName;
GridUtils.jdkVendor = jdkVendor; IgniteUtils.jdkVendor = jdkVendor;
GridUtils.jdkVer = jdkVer; IgniteUtils.jdkVer = jdkVer;
GridUtils.jdkStr = jdkStr; IgniteUtils.jdkStr = jdkStr;
GridUtils.osVer = osVer; IgniteUtils.osVer = osVer;
GridUtils.osArch = osArch; IgniteUtils.osArch = osArch;
GridUtils.jvmSpecName = jvmSpecName; IgniteUtils.jvmSpecName = jvmSpecName;
GridUtils.jvmImplVer = jvmImplVer; IgniteUtils.jvmImplVer = jvmImplVer;
GridUtils.jvmImplVendor = jvmImplVendor; IgniteUtils.jvmImplVendor = jvmImplVendor;
GridUtils.jvmImplName = jvmImplName; IgniteUtils.jvmImplName = jvmImplName;
GridUtils.javaRtName = javaRtName; IgniteUtils.javaRtName = javaRtName;
GridUtils.javaRtVer = javaRtVer; IgniteUtils.javaRtVer = javaRtVer;


primitiveMap.put("byte", byte.class); primitiveMap.put("byte", byte.class);
primitiveMap.put("short", short.class); primitiveMap.put("short", short.class);
Expand Down Expand Up @@ -2266,7 +2266,7 @@ public static boolean mkdirs(File dir) {
* @return Project home directory (or {@code null} if it cannot be resolved). * @return Project home directory (or {@code null} if it cannot be resolved).
*/ */
@Nullable private static String resolveProjectHome() { @Nullable private static String resolveProjectHome() {
assert Thread.holdsLock(GridUtils.class); assert Thread.holdsLock(IgniteUtils.class);


// Resolve GridGain home via environment variables. // Resolve GridGain home via environment variables.
String ggHome0 = IgniteSystemProperties.getString(GG_HOME); String ggHome0 = IgniteSystemProperties.getString(GG_HOME);
Expand All @@ -2285,7 +2285,7 @@ public static boolean mkdirs(File dir) {


URI uri; URI uri;


Class<GridUtils> cls = GridUtils.class; Class<IgniteUtils> cls = IgniteUtils.class;


try { try {
ProtectionDomain domain = cls.getProtectionDomain(); ProtectionDomain domain = cls.getProtectionDomain();
Expand Down Expand Up @@ -2354,7 +2354,7 @@ private static void logResolveFailed(Class cls, Exception e) {
String ggHome0; String ggHome0;


if (ggHomeTup == null) { if (ggHomeTup == null) {
synchronized (GridUtils.class) { synchronized (IgniteUtils.class) {
// Double check. // Double check.
ggHomeTup = ggHome; ggHomeTup = ggHome;


Expand Down Expand Up @@ -2384,7 +2384,7 @@ public static void setGridGainHome(@Nullable String path) {
String ggHome0; String ggHome0;


if (ggHomeTup == null) { if (ggHomeTup == null) {
synchronized (GridUtils.class) { synchronized (IgniteUtils.class) {
// Double check. // Double check.
ggHomeTup = ggHome; ggHomeTup = ggHome;


Expand Down Expand Up @@ -7477,7 +7477,7 @@ public static <K, V> void printConcurrentHashMapInfo(ConcurrentHashMap<K, V> map
int totalCollisions = 0; int totalCollisions = 0;


for (int i = 0; i < segs.length; i++) { for (int i = 0; i < segs.length; i++) {
int segCnt = GridUtils.<Integer>field(segs[i], "count"); int segCnt = IgniteUtils.<Integer>field(segs[i], "count");


if (segCnt == 0) { if (segCnt == 0) {
emptySegsCnt++; emptySegsCnt++;
Expand Down Expand Up @@ -8476,7 +8476,7 @@ public static void setWorkDirectory(@Nullable String userWorkDir, @Nullable Stri
String ggWork0 = ggWork; String ggWork0 = ggWork;


if (ggWork0 == null) { if (ggWork0 == null) {
synchronized (GridUtils.class) { synchronized (IgniteUtils.class) {
// Double check. // Double check.
ggWork0 = ggWork; ggWork0 = ggWork;


Expand Down Expand Up @@ -9074,7 +9074,7 @@ public static Comparator<InetSocketAddress> inetAddressesComparator(final boolea
public static <T extends R, R> List<R> arrayList(Collection<T> c, @Nullable IgnitePredicate<? super T>... p) { public static <T extends R, R> List<R> arrayList(Collection<T> c, @Nullable IgnitePredicate<? super T>... p) {
assert c != null; assert c != null;


return GridUtils.<T, R>arrayList(c, c.size(), p); return IgniteUtils.<T, R>arrayList(c, c.size(), p);
} }


/** /**
Expand Down
Expand Up @@ -20,9 +20,9 @@
import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.*;


/** /**
* Defines internal {@code typedef} for {@link GridUtils}. Since Java doesn't provide type aliases * Defines internal {@code typedef} for {@link IgniteUtils}. Since Java doesn't provide type aliases
* (like Scala, for example) we resort to these types of measures. This is intended for internal * (like Scala, for example) we resort to these types of measures. This is intended for internal
* use only and meant to provide for more terse code when readability of code is not compromised. * use only and meant to provide for more terse code when readability of code is not compromised.
*/ */
@SuppressWarnings({"ExtendsUtilityClass"}) @SuppressWarnings({"ExtendsUtilityClass"})
public class U extends GridUtils { /* No-op. */ } public class U extends IgniteUtils { /* No-op. */ }
Expand Up @@ -63,7 +63,7 @@ private VisorResolveHostNameJob(Void arg, boolean debug) {


try { try {
IgniteBiTuple<Collection<String>, Collection<String>> addrs = IgniteBiTuple<Collection<String>, Collection<String>> addrs =
GridUtils.resolveLocalAddresses(InetAddress.getByName("0.0.0.0")); IgniteUtils.resolveLocalAddresses(InetAddress.getByName("0.0.0.0"));


assert(addrs.get1() != null); assert(addrs.get1() != null);
assert(addrs.get2() != null); assert(addrs.get2() != null);
Expand Down
Expand Up @@ -53,8 +53,8 @@ private static String typeOf(Object o) {
if (o != null) { if (o != null) {
Class<?> clazz = o.getClass(); Class<?> clazz = o.getClass();


return clazz.isArray() ? GridUtils.compact(clazz.getComponentType().getName()) + "[]" return clazz.isArray() ? IgniteUtils.compact(clazz.getComponentType().getName()) + "[]"
: GridUtils.compact(o.getClass().getName()); : IgniteUtils.compact(o.getClass().getName());
} }
else else
return "n/a"; return "n/a";
Expand Down
Expand Up @@ -183,7 +183,7 @@ public void setClassNamesPath(@Nullable String path) throws IgniteCheckedExcepti
if (path == null) if (path == null)
return; return;


URL url = GridUtils.resolveGridGainUrl(path, false); URL url = IgniteUtils.resolveGridGainUrl(path, false);


if (url == null) if (url == null)
throw new IgniteCheckedException("Failed to find resource for name: " + path); throw new IgniteCheckedException("Failed to find resource for name: " + path);
Expand Down
Expand Up @@ -18,12 +18,11 @@
package org.apache.ignite; package org.apache.ignite;


import junit.framework.*; import junit.framework.*;
import org.apache.ignite.*;
import org.jetbrains.annotations.*; import org.jetbrains.annotations.*;


import java.util.*; import java.util.*;


import static org.apache.ignite.internal.util.GridUtils.*; import static org.apache.ignite.internal.util.IgniteUtils.*;


/** /**
* Tests for proper link output in stack traces. * Tests for proper link output in stack traces.
Expand Down
Expand Up @@ -233,7 +233,7 @@ else if (evtType == EVT_TASK_FAILED) {


/** /**
* Returns timestamp at the method call moment, but sleeps before return, * Returns timestamp at the method call moment, but sleeps before return,
* to allow pass {@link GridUtils#currentTimeMillis()}. * to allow pass {@link IgniteUtils#currentTimeMillis()}.
* *
* @return Call timestamp. * @return Call timestamp.
* @throws InterruptedException If sleep was interrupted. * @throws InterruptedException If sleep was interrupted.
Expand Down
Expand Up @@ -20,7 +20,7 @@
import org.apache.ignite.*; import org.apache.ignite.*;
import org.apache.ignite.cache.*; import org.apache.ignite.cache.*;
import org.apache.ignite.internal.*; import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.GridUtils; import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.lang.*;
import org.apache.ignite.testframework.*; import org.apache.ignite.testframework.*;
import org.apache.ignite.transactions.*; import org.apache.ignite.transactions.*;
Expand Down Expand Up @@ -739,7 +739,7 @@ private void checkTtl(boolean inTx) throws Exception {
} }


// One more update from the same cache entry to ensure that expire time is shifted forward. // One more update from the same cache entry to ensure that expire time is shifted forward.
GridUtils.sleep(100); IgniteUtils.sleep(100);


tx = inTx ? c.txStart() : null; tx = inTx ? c.txStart() : null;


Expand All @@ -764,7 +764,7 @@ private void checkTtl(boolean inTx) throws Exception {
} }


// And one more direct update to ensure that expire time is shifted forward. // And one more direct update to ensure that expire time is shifted forward.
GridUtils.sleep(100); IgniteUtils.sleep(100);


assertEquals(0, grid(0).cache(null).metrics().getCacheEvictions()); assertEquals(0, grid(0).cache(null).metrics().getCacheEvictions());


Expand All @@ -791,7 +791,7 @@ private void checkTtl(boolean inTx) throws Exception {
} }


// And one more update to ensure that ttl is not changed and expire time is not shifted forward. // And one more update to ensure that ttl is not changed and expire time is not shifted forward.
GridUtils.sleep(100); IgniteUtils.sleep(100);


assertEquals(0, grid(0).cache(null).metrics().getCacheEvictions()); assertEquals(0, grid(0).cache(null).metrics().getCacheEvictions());


Expand Down Expand Up @@ -864,7 +864,7 @@ public boolean applyx() throws IgniteCheckedException {
tx.commit(); tx.commit();
} }


GridUtils.sleep(2000); IgniteUtils.sleep(2000);


entry = c.entry(key); entry = c.entry(key);


Expand Down
Expand Up @@ -31,7 +31,7 @@
import java.util.*; import java.util.*;


import static org.apache.ignite.IgniteSystemProperties.*; import static org.apache.ignite.IgniteSystemProperties.*;
import static org.apache.ignite.internal.util.GridUtils.*; import static org.apache.ignite.internal.util.IgniteUtils.*;


/** /**
* Checks creation of work folder. * Checks creation of work folder.
Expand Down
Expand Up @@ -29,7 +29,7 @@
import org.apache.ignite.testframework.junits.common.*; import org.apache.ignite.testframework.junits.common.*;


import static org.apache.ignite.IgniteSystemProperties.*; import static org.apache.ignite.IgniteSystemProperties.*;
import static org.apache.ignite.internal.util.GridUtils.*; import static org.apache.ignite.internal.util.IgniteUtils.*;


/** /**
* Checks that node can be started without operations with undefined GRIDGAIN_HOME. * Checks that node can be started without operations with undefined GRIDGAIN_HOME.
Expand Down Expand Up @@ -58,7 +58,7 @@ public class GridStartupWithUndefinedGridGainHomeSelfTest extends TestCase {
* @throws Exception If failed. * @throws Exception If failed.
*/ */
public void testStartStopWithUndefinedGridGainHome() throws Exception { public void testStartStopWithUndefinedGridGainHome() throws Exception {
GridUtils.nullifyHomeDirectory(); IgniteUtils.nullifyHomeDirectory();


// We can't use U.getGridGainHome() here because // We can't use U.getGridGainHome() here because
// it will initialize cached value which is forbidden to override. // it will initialize cached value which is forbidden to override.
Expand Down
Expand Up @@ -17,22 +17,20 @@


package org.apache.ignite.internal.util; package org.apache.ignite.internal.util;


import org.apache.ignite.internal.util.*;

/** /**
* Clock timer for tests. * Clock timer for tests.
*/ */
public class GridTestClockTimer implements Runnable { public class GridTestClockTimer implements Runnable {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void run() { @Override public void run() {
while (true) { while (true) {
GridUtils.curTimeMillis = System.currentTimeMillis(); IgniteUtils.curTimeMillis = System.currentTimeMillis();


try { try {
Thread.sleep(10); Thread.sleep(10);
} }
catch (InterruptedException ignored) { catch (InterruptedException ignored) {
GridUtils.log(null, "Timer thread has been interrupted."); IgniteUtils.log(null, "Timer thread has been interrupted.");


break; break;
} }
Expand Down
Expand Up @@ -46,7 +46,7 @@
* Grid utils tests. * Grid utils tests.
*/ */
@GridCommonTest(group = "Utils") @GridCommonTest(group = "Utils")
public class GridUtilsSelfTest extends GridCommonAbstractTest { public class IgniteUtilsSelfTest extends GridCommonAbstractTest {
/** */ /** */
public static final int[] EMPTY = new int[0]; public static final int[] EMPTY = new int[0];


Expand Down Expand Up @@ -478,7 +478,7 @@ public void testsGetBytes() {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
UUID id = UUID.randomUUID(); UUID id = UUID.randomUUID();


byte[] bytes = GridUtils.uuidToBytes(id); byte[] bytes = IgniteUtils.uuidToBytes(id);
BigInteger n = new BigInteger(bytes); BigInteger n = new BigInteger(bytes);


assert n.shiftRight(Long.SIZE).longValue() == id.getMostSignificantBits(); assert n.shiftRight(Long.SIZE).longValue() == id.getMostSignificantBits();
Expand Down Expand Up @@ -696,7 +696,7 @@ public void testInetAddressesComparator() {




public void testMD5Calculation() throws Exception { public void testMD5Calculation() throws Exception {
String md5 = GridUtils.calculateMD5(new ByteArrayInputStream("Corrupted information.".getBytes())); String md5 = IgniteUtils.calculateMD5(new ByteArrayInputStream("Corrupted information.".getBytes()));


assertEquals("d7dbe555be2eee7fa658299850169fa1", md5); assertEquals("d7dbe555be2eee7fa658299850169fa1", md5);
} }
Expand Down
Expand Up @@ -120,7 +120,7 @@ public void testSetRemoveAll() throws Exception {
set.add("v4"); set.add("v4");
set.add("v5"); set.add("v5");


set.removeAll(GridUtils.addAll(new HashSet<String>(), "v2", "v4", "v5")); set.removeAll(IgniteUtils.addAll(new HashSet<String>(), "v2", "v4", "v5"));


assertEquals(2, set.size()); assertEquals(2, set.size());


Expand Down

0 comments on commit fc768b8

Please sign in to comment.