use of io.datarouter.web.handler.mav.imp.MessageMav in project datarouter by hotpads.
the class HBaseHandler method moveRegionsToCorrectServer.
/*---------------------------- move handlers ----------------------------*/
@Handler
public Mav moveRegionsToCorrectServer(OptionalInteger pauseBetweenRegionsMs) throws IOException {
initialize();
int counter = 0;
for (DrRegionInfo<?> region : regionList.get().getRegions()) {
if (!region.isOnCorrectServer()) {
++counter;
PhaseTimer timer = new PhaseTimer("move " + counter + " of " + datarouterWebRequestParams.getTableName());
String encodedRegionNameString = region.getRegion().getEncodedName();
String destinationServer = region.getConsistentHashServerName().getServerName();
hBaseClientManager.getAdmin(datarouterWebRequestParams.getClientId()).move(Bytes.toBytes(encodedRegionNameString), Bytes.toBytes(destinationServer));
logger.warn(timer.add("HBase moved region " + encodedRegionNameString + " to server " + destinationServer).toString());
}
ThreadTool.sleepUnchecked(pauseBetweenRegionsMs.orElse(500));
}
// mav.put("message-update", "HBase regions moved to correct server");
return new MessageMav("HBase regions moved to correct server");
}
use of io.datarouter.web.handler.mav.imp.MessageMav in project datarouter by hotpads.
the class HBaseHandler method majorCompactHBaseTableRegions.
@Handler
public Mav majorCompactHBaseTableRegions() throws IOException {
initialize();
for (String encodedRegionNameString : encodedRegionNameStrings) {
DrRegionInfo<?> region = regionList.get().getRegionByEncodedName(encodedRegionNameString);
hBaseClientManager.getAdmin(datarouterWebRequestParams.getClientId()).majorCompactRegion(region.getRegion().getRegionName());
}
return new MessageMav("submitted major compaction requests for regions: " + encodedRegionNameStrings);
}
use of io.datarouter.web.handler.mav.imp.MessageMav in project datarouter by hotpads.
the class HBaseHandler method updateHBaseTableAttribute.
/*---------------------------- update handlers --------------------------*/
@Handler
public Mav updateHBaseTableAttribute(OptionalLong maxFileSizeMb, OptionalLong memstoreFlushSizeMb) throws IOException {
initialize();
Admin admin = hBaseClientManager.getAdmin(datarouterWebRequestParams.getClientId());
HTableDescriptor table;
table = admin.getTableDescriptor(TableName.valueOf(datarouterWebRequestParams.getTableName().getBytes()));
try {
admin.disableTable(TableName.valueOf(datarouterWebRequestParams.getTableName()));
logger.warn("table disabled");
maxFileSizeMb.map(mb -> mb * 1024 * 1024).ifPresent(table::setMaxFileSize);
memstoreFlushSizeMb.map(mb -> mb * 1024 * 1024).ifPresent(table::setMemStoreFlushSize);
admin.modifyTable(TableName.valueOf(StringCodec.UTF_8.encode(datarouterWebRequestParams.getTableName())), table);
} finally {
admin.enableTable(TableName.valueOf(datarouterWebRequestParams.getTableName()));
}
logger.warn("table enabled");
mav = new MessageMav("HBase table attributes updated");
return mav;
}
use of io.datarouter.web.handler.mav.imp.MessageMav in project datarouter by hotpads.
the class DatarouterPermissionRequestHandler method showForm.
@Handler(defaultHandler = true)
private Mav showForm(OptionalString deniedUrl, OptionalString allowedRoles) {
if (!authenticationConfig.useDatarouterAuthentication()) {
return new MessageMav(noDatarouterAuthentication());
}
Mav mav = new Mav(files.jsp.authentication.permissionRequestJsp);
mav.put("serviceName", serviceName.get());
mav.put("permissionRequestPath", paths.permissionRequest.toSlashedString());
Optional<String> defaultSpecifics = deniedUrl.map(url -> {
return "I tried to go to this URL: " + url + "." + allowedRoles.map(" These are its allowed roles at the time of this request: "::concat).orElse("");
});
mav.put("defaultSpecifics", defaultSpecifics);
DatarouterUser user = getCurrentUser();
mav.put("currentRequest", datarouterPermissionRequestDao.scanOpenPermissionRequestsForUser(user.getId()).findMax(Comparator.comparing(request -> request.getKey().getRequestTime())).orElse(null));
Set<String> emails = new HashSet<>();
if (serverTypeDetector.mightBeProduction()) {
emails.addAll(permissionRequestEmailType.tos);
}
emails.add(adminEmail.get());
if (subscribersSettings.includeSubscribers.get()) {
emails.addAll(subscibersEmail.get());
}
mav.put("email", emails);
mav.put("submitPath", paths.permissionRequest.submit.join("/"));
mav.put("declinePath", paths.permissionRequest.declineAll.join("/"));
return mav;
}
use of io.datarouter.web.handler.mav.imp.MessageMav in project datarouter by hotpads.
the class DatarouterPermissionRequestHandler method submit.
@Handler
private Mav submit(OptionalString specifics) {
if (!authenticationConfig.useDatarouterAuthentication()) {
return new MessageMav(noDatarouterAuthentication());
}
String reason = params.required(P_REASON);
if (StringTool.isEmpty(reason)) {
throw new IllegalArgumentException("Reason is required.");
}
String specificString = specifics.orElse("");
DatarouterUser user = getCurrentUser();
datarouterPermissionRequestDao.createPermissionRequest(new DatarouterPermissionRequest(user.getId(), new Date(), "reason: " + reason + ", specifics: " + specificString, null, null));
sendRequestEmail(user, reason, specificString);
// not just requestor, so send them to the home page after they make their request
if (user.getRoles().size() > 1) {
return new InContextRedirectMav(request, paths.home);
}
return showForm(new OptionalString(null), new OptionalString(null));
}
Aggregations