mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
[java] change RayLog.core to org.slf4j.Logger (#3579)
This commit is contained in:
parent
e046a5c767
commit
e65b8f18f4
8 changed files with 54 additions and 38 deletions
|
@ -5,7 +5,6 @@ import org.ray.api.id.UniqueId;
|
|||
import org.ray.runtime.functionmanager.RayFunction;
|
||||
import org.ray.runtime.task.ArgumentsBuilder;
|
||||
import org.ray.runtime.task.TaskSpec;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -63,9 +62,9 @@ public class Worker {
|
|||
} else {
|
||||
runtime.localActors.put(returnId, result);
|
||||
}
|
||||
RayLog.core.info("Finished executing task {}", spec.taskId);
|
||||
LOGGER.info("Finished executing task {}", spec.taskId);
|
||||
} catch (Exception e) {
|
||||
RayLog.core.error("Error executing task " + spec, e);
|
||||
LOGGER.error("Error executing task " + spec, e);
|
||||
runtime.put(returnId, new RayException("Error executing task " + spec, e));
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(oldLoader);
|
||||
|
|
|
@ -11,13 +11,15 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.ray.api.id.UniqueId;
|
||||
import org.ray.runtime.generated.ClientTableData;
|
||||
import org.ray.runtime.util.NetworkUtil;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A class used to interface with the Ray control state.
|
||||
*/
|
||||
public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StateStoreProxyImpl.class);
|
||||
public KeyValueStoreLink rayKvStore;
|
||||
public ArrayList<KeyValueStoreLink> shardStoreList = new ArrayList<>();
|
||||
|
||||
|
@ -87,11 +89,11 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
|||
return doGetAddressInfo(nodeIpAddress, redisAddress);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
RayLog.core.warn("Error occurred in StateStoreProxyImpl getAddressInfo, "
|
||||
+ (numRetries - count) + " retries remaining", e);
|
||||
LOGGER.warn("Error occurred in StateStoreProxyImpl getAddressInfo, {} retries remaining",
|
||||
(numRetries - count), e);
|
||||
TimeUnit.MILLISECONDS.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
RayLog.core.error("error at StateStoreProxyImpl getAddressInfo", e);
|
||||
LOGGER.error("error at StateStoreProxyImpl getAddressInfo", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,15 @@ import org.apache.arrow.plasma.ObjectStoreLink;
|
|||
import org.ray.api.id.UniqueId;
|
||||
import org.ray.runtime.RayDevRuntime;
|
||||
import org.ray.runtime.raylet.MockRayletClient;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A mock implementation of {@code org.ray.spi.ObjectStoreLink}, which use Map to store data.
|
||||
*/
|
||||
public class MockObjectStore implements ObjectStoreLink {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MockObjectStore.class);
|
||||
private final RayDevRuntime runtime;
|
||||
private final Map<UniqueId, byte[]> data = new ConcurrentHashMap<>();
|
||||
private final Map<UniqueId, byte[]> metadata = new ConcurrentHashMap<>();
|
||||
|
@ -28,8 +30,8 @@ public class MockObjectStore implements ObjectStoreLink {
|
|||
@Override
|
||||
public void put(byte[] objectId, byte[] value, byte[] metadataValue) {
|
||||
if (objectId == null || objectId.length == 0 || value == null) {
|
||||
RayLog.core
|
||||
.error(logPrefix() + "cannot put null: " + objectId + "," + Arrays.toString(value));
|
||||
LOGGER
|
||||
.error("{} cannot put null: {}, {}", logPrefix(), objectId, Arrays.toString(value));
|
||||
System.exit(-1);
|
||||
}
|
||||
UniqueId uniqueId = new UniqueId(objectId);
|
||||
|
@ -48,7 +50,7 @@ public class MockObjectStore implements ObjectStoreLink {
|
|||
ArrayList<byte[]> rets = new ArrayList<>(objectIds.length);
|
||||
for (byte[] objId : objectIds) {
|
||||
UniqueId uniqueId = new UniqueId(objId);
|
||||
RayLog.core.info(logPrefix() + " is notified for objectid " + uniqueId);
|
||||
LOGGER.info("{} is notified for objectid {}",logPrefix(), uniqueId);
|
||||
rets.add(dataMap.get(uniqueId));
|
||||
}
|
||||
return rets;
|
||||
|
|
|
@ -20,10 +20,13 @@ import org.ray.runtime.generated.TaskInfo;
|
|||
import org.ray.runtime.task.FunctionArg;
|
||||
import org.ray.runtime.task.TaskSpec;
|
||||
import org.ray.runtime.util.UniqueIdUtil;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RayletClientImpl implements RayletClient {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RayletClientImpl.class);
|
||||
|
||||
private static final int TASK_SPEC_BUFFER_SIZE = 2 * 1024 * 1024;
|
||||
|
||||
/**
|
||||
|
@ -70,7 +73,7 @@ public class RayletClientImpl implements RayletClient {
|
|||
|
||||
@Override
|
||||
public void submitTask(TaskSpec spec) {
|
||||
RayLog.core.debug("Submitting task: {}", spec);
|
||||
LOGGER.debug("Submitting task: {}", spec);
|
||||
ByteBuffer info = convertTaskSpecToFlatbuffer(spec);
|
||||
byte[] cursorId = null;
|
||||
if (!spec.getExecutionDependencies().isEmpty()) {
|
||||
|
@ -91,8 +94,8 @@ public class RayletClientImpl implements RayletClient {
|
|||
@Override
|
||||
public void fetchOrReconstruct(List<UniqueId> objectIds, boolean fetchOnly,
|
||||
UniqueId currentTaskId) {
|
||||
if (RayLog.core.isDebugEnabled()) {
|
||||
RayLog.core.debug("Blocked on objects for task {}, object IDs are {}",
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("Blocked on objects for task {}, object IDs are {}",
|
||||
UniqueIdUtil.computeTaskId(objectIds.get(0)), objectIds);
|
||||
}
|
||||
int ret = nativeFetchOrReconstruct(client, UniqueIdUtil.getIdBytes(objectIds),
|
||||
|
@ -254,9 +257,9 @@ public class RayletClientImpl implements RayletClient {
|
|||
ByteBuffer buffer = fbb.dataBuffer();
|
||||
|
||||
if (buffer.remaining() > TASK_SPEC_BUFFER_SIZE) {
|
||||
RayLog.core.error(
|
||||
"Allocated buffer is not enough to transfer the task specification: "
|
||||
+ TASK_SPEC_BUFFER_SIZE + " vs " + buffer.remaining());
|
||||
LOGGER.error(
|
||||
"Allocated buffer is not enough to transfer the task specification: {}vs {}",
|
||||
TASK_SPEC_BUFFER_SIZE, buffer.remaining());
|
||||
assert (false);
|
||||
}
|
||||
return buffer;
|
||||
|
|
|
@ -7,10 +7,13 @@ import java.net.InetAddress;
|
|||
import java.net.NetworkInterface;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.Enumeration;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class NetworkUtil {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NetworkUtil.class);
|
||||
|
||||
public static String getIpAddress(String interfaceName) {
|
||||
try {
|
||||
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
||||
|
@ -35,9 +38,9 @@ public class NetworkUtil {
|
|||
return addr.getHostAddress();
|
||||
}
|
||||
}
|
||||
RayLog.core.warn("You need to correctly specify [ray.java] net_interface in config.");
|
||||
LOGGER.warn("You need to correctly specify [ray.java] net_interface in config.");
|
||||
} catch (Exception e) {
|
||||
RayLog.core.error("Can't get ip address, use 127.0.0.1 as default.", e);
|
||||
LOGGER.error("Can't get ip address, use 127.0.0.1 as default.", e);
|
||||
}
|
||||
|
||||
return "127.0.0.1";
|
||||
|
|
|
@ -2,15 +2,17 @@ package org.ray.runtime.util;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Sha1Digestor {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Sha1Digestor.class);
|
||||
private static final ThreadLocal<MessageDigest> md = ThreadLocal.withInitial(() -> {
|
||||
try {
|
||||
return MessageDigest.getInstance("SHA1");
|
||||
} catch (Exception e) {
|
||||
RayLog.core.error("Cannot get SHA1 MessageDigest", e);
|
||||
LOGGER.error("Cannot get SHA1 MessageDigest", e);
|
||||
throw new RuntimeException("Cannot get SHA1 digest", e);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,13 +3,16 @@ package org.ray.runtime.util;
|
|||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* some utilities for system process.
|
||||
*/
|
||||
public class SystemUtil {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SystemUtil.class);
|
||||
|
||||
static final ReentrantLock pidlock = new ReentrantLock();
|
||||
static Integer pid;
|
||||
|
||||
|
@ -34,7 +37,7 @@ public class SystemUtil {
|
|||
} catch (ClassNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
RayLog.core.error("error at SystemUtil startWithJar", e);
|
||||
LOGGER.error("error at SystemUtil startWithJar", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,12 @@ import org.ray.api.Ray;
|
|||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.annotation.RayRemote;
|
||||
import org.ray.runtime.util.logger.RayLog;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class RayBenchmarkTest<T> implements Serializable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RayBenchmarkTest.class);
|
||||
//not thread safe ,but we only have one thread here
|
||||
public static final DecimalFormat df = new DecimalFormat("00.00");
|
||||
private static final long serialVersionUID = 416045641835782523L;
|
||||
|
@ -61,12 +63,12 @@ public abstract class RayBenchmarkTest<T> implements Serializable {
|
|||
long endTime = remoteResult.getFinishTime();
|
||||
long costTime = endTime - temp.getStartTime();
|
||||
counterList.add(costTime / 1000);
|
||||
RayLog.core.warn(logPrefix + "_cost_time:" + costTime + "ns");
|
||||
LOGGER.warn("{}_cost_time:{}ns",logPrefix, costTime);
|
||||
Assert.assertTrue(rayBenchmarkTest.checkResult(remoteResult.getResult()));
|
||||
}
|
||||
return counterList;
|
||||
} catch (Exception e) {
|
||||
RayLog.core.error("singleClient", e);
|
||||
LOGGER.error("singleClient", e);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ public abstract class RayBenchmarkTest<T> implements Serializable {
|
|||
long endTime = System.nanoTime();
|
||||
long costTime = endTime - startTime;
|
||||
counterList.add(costTime / 1000);
|
||||
RayLog.core.warn("SINGLE_LATENCY_cost_time: " + costTime + " us");
|
||||
LOGGER.warn("SINGLE_LATENCY_cost_time: {} us", costTime);
|
||||
Assert.assertTrue(checkResult(t));
|
||||
}
|
||||
Collections.sort(counterList);
|
||||
|
@ -103,15 +105,15 @@ public abstract class RayBenchmarkTest<T> implements Serializable {
|
|||
int ninety = (int) (len * 0.9);
|
||||
int fifty = (int) (len * 0.5);
|
||||
|
||||
RayLog.core.error("Final result of rt as below:");
|
||||
RayLog.core.error("max: " + list.get(len - 1) + "μs");
|
||||
RayLog.core.error("min: " + list.get(0) + "μs");
|
||||
RayLog.core.error("median: " + list.get(middle) + "μs");
|
||||
RayLog.core.error("99.99% data smaller than: " + list.get(almostHundred) + "μs");
|
||||
RayLog.core.error("99% data smaller than: " + list.get(ninetyNine) + "μs");
|
||||
RayLog.core.error("95% data smaller than: " + list.get(ninetyFive) + "μs");
|
||||
RayLog.core.error("90% data smaller than: " + list.get(ninety) + "μs");
|
||||
RayLog.core.error("50% data smaller than: " + list.get(fifty) + "μs");
|
||||
LOGGER.error("Final result of rt as below:");
|
||||
LOGGER.error("max: {}μs", list.get(len - 1));
|
||||
LOGGER.error("min: {}μs", list.get(0));
|
||||
LOGGER.error("median: {}μs", list.get(middle));
|
||||
LOGGER.error("99.99% data smaller than: {}μs", list.get(almostHundred));
|
||||
LOGGER.error("99% data smaller than: {}μs", list.get(ninetyNine));
|
||||
LOGGER.error("95% data smaller than: {}μs", list.get(ninetyFive));
|
||||
LOGGER.error("90% data smaller than: {}μs", list.get(ninety));
|
||||
LOGGER.error("50% data smaller than: {}μs", list.get(fifty));
|
||||
}
|
||||
|
||||
public void rateLimiterPressureTest(PressureTestParameter pressureTestParameter) {
|
||||
|
|
Loading…
Add table
Reference in a new issue