Skip to content

Commit

Permalink
replace subdirectory with jvmId
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Oct 6, 2023
1 parent e9ddcaf commit 5020eeb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.cryostat.net.web.http.api.v2.ApiException;
import io.cryostat.net.web.http.api.v2.IntermediateResponse;
import io.cryostat.net.web.http.api.v2.RequestParameters;
import io.cryostat.recordings.JvmIdHelper;
import io.cryostat.recordings.RecordingArchiveHelper;
import io.cryostat.recordings.RecordingNotFoundException;
import io.cryostat.rules.ArchivePathException;
Expand All @@ -40,17 +41,20 @@

public class RecordingDeleteFromPathHandler extends AbstractV2RequestHandler<Void> {

static final String PATH = "fs/recordings/:subdirectoryName/:recordingName";
static final String PATH = "fs/recordings/:jvmId/:recordingName";

private final RecordingArchiveHelper recordingArchiveHelper;
private final JvmIdHelper jvmIdHelper;

@Inject
RecordingDeleteFromPathHandler(
AuthManager auth,
CredentialsManager credentialsManager,
Gson gson,
JvmIdHelper jvmIdHelper,
RecordingArchiveHelper recordingArchiveHelper) {
super(auth, credentialsManager, gson);
this.jvmIdHelper = jvmIdHelper;
this.recordingArchiveHelper = recordingArchiveHelper;
}

Expand Down Expand Up @@ -91,9 +95,10 @@ public boolean isAsync() {

@Override
public IntermediateResponse<Void> handle(RequestParameters params) throws Exception {
String subdirectoryName = params.getPathParams().get("subdirectoryName");
String recordingName = params.getPathParams().get("recordingName");
String jvmId = params.getPathParams().get("jvmId");
try {
String subdirectoryName = jvmIdHelper.jvmIdToSubdirectoryName(jvmId);
recordingArchiveHelper.deleteRecordingFromPath(subdirectoryName, recordingName).get();
return new IntermediateResponse<Void>().body(null);
} catch (ExecutionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io.cryostat.net.web.http.api.v2.ApiException;
import io.cryostat.net.web.http.api.v2.IntermediateResponse;
import io.cryostat.net.web.http.api.v2.RequestParameters;
import io.cryostat.recordings.JvmIdHelper;
import io.cryostat.recordings.RecordingArchiveHelper;
import io.cryostat.recordings.RecordingMetadataManager;
import io.cryostat.recordings.RecordingMetadataManager.Metadata;
Expand All @@ -41,21 +42,24 @@

public class RecordingMetadataLabelsPostFromPathHandler extends AbstractV2RequestHandler<Metadata> {

static final String PATH = "fs/recordings/:subdirectoryName/:recordingName/metadata/labels";
static final String PATH = "fs/recordings/:jvmId/:recordingName/metadata/labels";

private final RecordingArchiveHelper recordingArchiveHelper;
private final RecordingMetadataManager recordingMetadataManager;
private final JvmIdHelper jvmIdHelper;

@Inject
RecordingMetadataLabelsPostFromPathHandler(
AuthManager auth,
CredentialsManager credentialsManager,
Gson gson,
JvmIdHelper jvmIdHelper,
RecordingArchiveHelper recordingArchiveHelper,
RecordingMetadataManager recordingMetadataManager) {
super(auth, credentialsManager, gson);
this.recordingArchiveHelper = recordingArchiveHelper;
this.recordingMetadataManager = recordingMetadataManager;
this.jvmIdHelper = jvmIdHelper;
}

@Override
Expand Down Expand Up @@ -96,9 +100,9 @@ public boolean requiresAuthentication() {
@Override
public IntermediateResponse<Metadata> handle(RequestParameters params) throws Exception {
String recordingName = params.getPathParams().get("recordingName");
String subdirectoryName = params.getPathParams().get("subdirectoryName");

String jvmId = params.getPathParams().get("jvmId");
try {
String subdirectoryName = jvmIdHelper.jvmIdToSubdirectoryName(jvmId);
Metadata metadata =
new Metadata(recordingMetadataManager.parseRecordingLabels(params.getBody()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.cryostat.net.web.http.api.v2.ApiException;
import io.cryostat.net.web.http.api.v2.IntermediateResponse;
import io.cryostat.net.web.http.api.v2.RequestParameters;
import io.cryostat.recordings.JvmIdHelper;
import io.cryostat.recordings.RecordingArchiveHelper;
import io.cryostat.recordings.RecordingNotFoundException;
import io.cryostat.rules.ArchivePathException;
Expand All @@ -56,11 +57,12 @@

class RecordingUploadPostFromPathHandler extends AbstractV2RequestHandler<String> {

static final String PATH = "fs/recordings/:subdirectoryName/:recordingName/upload";
static final String PATH = "fs/recordings/:jvmId/:recordingName/upload";

private final Environment env;
private final long httpTimeoutSeconds;
private final WebClient webClient;
private final JvmIdHelper jvmIdHelper;
private final RecordingArchiveHelper recordingArchiveHelper;

@Inject
Expand All @@ -70,12 +72,14 @@ class RecordingUploadPostFromPathHandler extends AbstractV2RequestHandler<String
Environment env,
@Named(HttpModule.HTTP_REQUEST_TIMEOUT_SECONDS) long httpTimeoutSeconds,
WebClient webClient,
JvmIdHelper jvmIdHelper,
RecordingArchiveHelper recordingArchiveHelper,
Gson gson) {
super(auth, credentialsManager, gson);
this.env = env;
this.httpTimeoutSeconds = httpTimeoutSeconds;
this.webClient = webClient;
this.jvmIdHelper = jvmIdHelper;
this.recordingArchiveHelper = recordingArchiveHelper;
}

Expand Down Expand Up @@ -116,9 +120,10 @@ public boolean isAsync() {

@Override
public IntermediateResponse<String> handle(RequestParameters params) throws Exception {
String subdirectoryName = params.getPathParams().get("subdirectoryName");
String recordingName = params.getPathParams().get("recordingName");
String jvmId = params.getPathParams().get("jvmId");
try {
String subdirectoryName = jvmIdHelper.jvmIdToSubdirectoryName(jvmId);
URL uploadUrl = new URL(env.getEnv(Variables.GRAFANA_DATASOURCE_ENV));
boolean isValidUploadUrl =
new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS).isValid(uploadUrl.toString());
Expand Down

0 comments on commit 5020eeb

Please sign in to comment.