Skip to content

Commit

Permalink
dcache-qos,frontend: add exception to remote client method and return…
Browse files Browse the repository at this point in the history
… 500 if fails

Motivation:

See GitHub issue #6914.
If there are no qos services running, the namespace qos transition
should fail.

Modification:

Change the send of that message to sendAndWait with message return;
catch and handle the checked exceptions.

Result:

Desired behavior (returns 500 with error message when services are
not reachable).

Target: master
Request: 8.2
Request: 8.1
Patch: https://rb.dcache.org/r/13810/
Requires-notes: yes
Requires-book: no
Closes: #6914
Acked-by: Tigran
  • Loading branch information
alrossi authored and lemora committed Dec 14, 2022
1 parent d7760ad commit 8199c72
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
Expand Up @@ -69,6 +69,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import diskCacheV111.util.NamespaceHandlerAware;
import diskCacheV111.util.PnfsHandler;
import diskCacheV111.util.PnfsId;
import dmg.cells.nucleus.NoRouteToCellException;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -148,7 +149,12 @@ public ListenableFuture<QoSTransitionCompletedMessage> perform(String rid, long

RemoteQoSRequirementsClient client = new RemoteQoSRequirementsClient();
client.setRequirementsService(qosEngine);
client.fileQoSRequirementsModified(requirements);

try {
client.fileQoSRequirementsModified(requirements);
} catch (CacheException | InterruptedException | NoRouteToCellException e) {
return Futures.immediateFailedFuture(e);
}

return future;
}
Expand Down
Expand Up @@ -534,6 +534,8 @@ public Response cmrResources(
} catch (NoAttributeCacheException e) {
throw new WebApplicationException(Response.status(409, "No such attribute")
.build());
} catch (NoRouteToCellException | InterruptedException e) {
throw new InternalServerErrorException(e.toString());
} catch (UnsupportedOperationException |
URISyntaxException |
JSONException |
Expand Down
Expand Up @@ -151,12 +151,13 @@ public MessageReply<QoSRequirementsRequestMessage> messageArrived(
return reply;
}

public void messageArrived(QoSRequirementsModifiedMessage message) {
public QoSRequirementsModifiedMessage messageArrived(QoSRequirementsModifiedMessage message) {
if (messageGuard.getStatus("QoSRequirementsModifiedMessage", message)
== Status.DISABLED) {
return;
return message;
}
fileStatusHandler.handleQoSModification(message.getRequirements());
return message;
}

public void messageArrived(QoSCancelRequirementsModifiedMessage message) {
Expand Down
Expand Up @@ -67,8 +67,10 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import static org.dcache.qos.data.QoSMessageType.QOS_MODIFIED_CANCELED;
import static org.dcache.qos.services.engine.util.QoSEngineCounters.QOS_ACTION_COMPLETED;

import diskCacheV111.util.CacheException;
import diskCacheV111.util.PnfsId;
import dmg.cells.nucleus.CellInfoProvider;
import dmg.cells.nucleus.NoRouteToCellException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.concurrent.ExecutorService;
Expand Down Expand Up @@ -167,10 +169,9 @@ public void handleQoSModification(FileQoSRequirements requirements) {
LOGGER.debug("handleQoSModification calling fileQoSStatusChanged for {}, {}.",
pnfsId, QOS_MODIFIED);
fileQoSStatusChanged(new FileQoSUpdate(pnfsId, null, QOS_MODIFIED));
} catch (QoSException e) {
} catch (QoSException | CacheException | NoRouteToCellException | InterruptedException e) {
LOGGER.error("Failed to handle QoS requirements for {}: {}.",
requirements.getPnfsId(),
e.toString());
requirements.getPnfsId(), e.getMessage());
handleActionCompleted(pnfsId, VOID, e.toString());
}
});
Expand Down
Expand Up @@ -59,7 +59,9 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
*/
package org.dcache.qos.listeners;

import diskCacheV111.util.CacheException;
import diskCacheV111.util.PnfsId;
import dmg.cells.nucleus.NoRouteToCellException;
import org.dcache.qos.QoSException;
import org.dcache.qos.data.FileQoSRequirements;
import org.dcache.qos.data.FileQoSUpdate;
Expand All @@ -81,7 +83,8 @@ public interface QoSRequirementsListener {
* @param newRequirements describing principally how many peristent disk and tape copies are
* required.
*/
void fileQoSRequirementsModified(FileQoSRequirements newRequirements) throws QoSException;
void fileQoSRequirementsModified(FileQoSRequirements newRequirements)
throws QoSException, CacheException, NoRouteToCellException, InterruptedException;

/**
* A client sends this when it wishes to cancel a modification requirement.
Expand Down
Expand Up @@ -60,7 +60,9 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
package org.dcache.qos.remote.clients;

import com.google.common.util.concurrent.ListenableFuture;
import diskCacheV111.util.CacheException;
import diskCacheV111.util.PnfsId;
import dmg.cells.nucleus.NoRouteToCellException;
import java.io.Serializable;
import java.util.concurrent.ExecutionException;
import org.dcache.cells.CellStub;
Expand Down Expand Up @@ -108,11 +110,9 @@ public FileQoSRequirements fileQoSRequirementsRequested(FileQoSUpdate update)
}

@Override
public void fileQoSRequirementsModified(FileQoSRequirements newRequirements) {
/*
* Fire and forget. The sender will need to listen for a response.
*/
requirementsService.send(new QoSRequirementsModifiedMessage(newRequirements));
public void fileQoSRequirementsModified(FileQoSRequirements newRequirements)
throws CacheException, NoRouteToCellException, InterruptedException {
requirementsService.sendAndWait(new QoSRequirementsModifiedMessage(newRequirements));
}

@Override
Expand Down

0 comments on commit 8199c72

Please sign in to comment.