Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createStoreRequest class and refactor CreateStore class to use it #1247

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,40 @@ public void internalHandle(Request request, NewStoreResponse veniceResponse) {
return;
}
AdminSparkServer.validateParams(request, NEW_STORE.getParams(), admin);
String clusterName = request.queryParams(CLUSTER);
String storeName = request.queryParams(NAME);
String keySchema = request.queryParams(KEY_SCHEMA);
String valueSchema = request.queryParams(VALUE_SCHEMA);
boolean isSystemStore = Boolean.parseBoolean(request.queryParams(IS_SYSTEM_STORE));

String owner = AdminSparkServer.getOptionalParameterValue(request, OWNER);
if (owner == null) {
owner = "";
}

String accessPerm = request.queryParams(ACCESS_PERMISSION);
Optional<String> accessPermissions = Optional.ofNullable(accessPerm);
CreateStoreRequest createStoreRequest = new CreateStoreRequest();
createStoreRequest.setClusterName(request.queryParams(CLUSTER));
createStoreRequest.setStoreName(request.queryParams(NAME));
createStoreRequest.setKeySchema(request.queryParams(KEY_SCHEMA));
createStoreRequest.setValueSchema(request.queryParams(VALUE_SCHEMA));
createStoreRequest.setSystemStore(Boolean.parseBoolean(request.queryParams(IS_SYSTEM_STORE)));
createStoreRequest.setAccessPerm(request.queryParams(ACCESS_PERMISSION));
createStoreRequest.setOwner(owner);

veniceResponse.setCluster(createStoreRequest.getClusterName());
veniceResponse.setName(createStoreRequest.getStoreName());
veniceResponse.setOwner(createStoreRequest.getOwner());

veniceResponse.setCluster(clusterName);
veniceResponse.setName(storeName);
veniceResponse.setOwner(owner);
admin.createStore(clusterName, storeName, owner, keySchema, valueSchema, isSystemStore, accessPermissions);
createStore(createStoreRequest, admin);
}
};
}

private void createStore(CreateStoreRequest request, Admin admin) {
admin.createStore(
request.getClusterName(),
request.getStoreName(),
request.getOwner(),
request.getKeySchema(),
request.getValueSchema(),
request.isSystemStore(),
Optional.ofNullable(request.getAccessPerm()));
}

/**
* @see Admin#updateAclForStore(String, String, String)
*/
Expand Down Expand Up @@ -155,5 +167,4 @@ public Route checkResourceCleanupForStoreCreation(Admin admin) {
return AdminSparkServer.OBJECT_MAPPER.writeValueAsString(controllerResponse);
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.linkedin.venice.controller.server;

public class CreateStoreRequest {
private String clusterName;
private String storeName;
private String keySchema;
private String valueSchema;
private boolean isSystemStore;
private String owner;
private String accessPerm;

public CreateStoreRequest(
String clusterName,
String storeName,
String keySchema,
String valueSchema,
boolean isSystemStore,
String accessPerm) {
this.clusterName = clusterName;
this.storeName = storeName;
this.keySchema = keySchema;
this.valueSchema = valueSchema;
this.isSystemStore = isSystemStore;
this.accessPerm = accessPerm;
}

public CreateStoreRequest() {
}

public String getClusterName() {
return clusterName;
}

public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}

public String getStoreName() {
return storeName;
}

public void setStoreName(String storeName) {
this.storeName = storeName;
}

public String getKeySchema() {
return keySchema;
}

public void setKeySchema(String keySchema) {
this.keySchema = keySchema;
}

public String getValueSchema() {
return valueSchema;
}

public void setValueSchema(String valueSchema) {
this.valueSchema = valueSchema;
}

public boolean isSystemStore() {
return isSystemStore;
}

public void setSystemStore(boolean isSystemStore) {
this.isSystemStore = isSystemStore;
}

public String getOwner() {
return owner;
}

public void setOwner(String owner) {
this.owner = owner;
}

public String getAccessPerm() {
return accessPerm;
}

public void setAccessPerm(String accessPerm) {
this.accessPerm = accessPerm;
}
}
Loading