Skip to content

Commit

Permalink
Merge pull request #119 from arenadata/update-release-branch
Browse files Browse the repository at this point in the history
[Release] Port commits to release branch
  • Loading branch information
iamlapa authored Sep 27, 2024
2 parents 9c77013 + f12f366 commit d206ac8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import static org.smartdata.utils.ConfigUtil.getSsmRpcAddresses;
Expand All @@ -57,7 +58,7 @@ public class SmartClient implements Closeable, SmartClientProtocol {
private final PathChecker pathChecker;
private final FileAccessReportStrategy fileAccessReportStrategy;
private final ActiveServerAddressCache activeServerAddressCache;
private volatile boolean running = true;
private final AtomicBoolean running;

public SmartClient(Configuration conf) throws IOException {
this(conf, getSsmRpcAddresses(conf));
Expand All @@ -84,6 +85,7 @@ public SmartClient(
this.smartServerHandles = new SmartServerHandles(
initializeServerHandles(ssmRpcAddresses));
this.fileAccessReportStrategy = FileAccessReportStrategy.from(conf, smartServerHandles);
this.running = new AtomicBoolean(true);
}

private List<SmartServerHandle> initializeServerHandles(
Expand Down Expand Up @@ -172,8 +174,7 @@ public boolean shouldIgnore(String path) {

@Override
public void close() throws IOException {
if (running) {
running = false;
if (running.compareAndSet(true, false)) {
for (SmartServerHandle server : smartServerHandles.handles()) {
RPC.stopProxy(server.getProtocol());
}
Expand All @@ -194,7 +195,7 @@ private Collection<InetSocketAddress> getOrderedServerAddresses(
}

private void checkOpen() throws IOException {
if (!running) {
if (!running.get()) {
throw new IOException("SmartClient closed");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
import org.smartdata.protocol.ClientServerProto.ReportFileAccessEventRequestProto;
import org.smartdata.protocol.SmartClientProtocol;

import java.io.Closeable;
import java.io.IOException;

import static org.smartdata.protocol.protobuffer.ProtoBufferHelper.ipc;

public class ClientProtocolClientSideTranslator implements
java.io.Closeable, SmartClientProtocol {
private ClientProtocolProtoBuffer rpcProxy;
Closeable, SmartClientProtocol {

private final ClientProtocolProtoBuffer rpcProxy;

public ClientProtocolClientSideTranslator(
ClientProtocolProtoBuffer proxy) {
Expand All @@ -41,7 +43,6 @@ public ClientProtocolClientSideTranslator(
@Override
public void close() throws IOException {
RPC.stopProxy(rpcProxy);
rpcProxy = null;
}

@Override
Expand Down

0 comments on commit d206ac8

Please sign in to comment.