Search in sources :

Example 1 with DatarouterChangelogDtoBuilder

use of io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder in project datarouter by hotpads.

the class TableCountHandler method deleteRowSamples.

@Handler
private Mav deleteRowSamples(String clientName, String tableName) {
    // delete rows from TableSample
    var tableSampleKeyPrefix = new TableSampleKey(clientName, tableName, null, null);
    tableSampleDao.deleteWithPrefix(tableSampleKeyPrefix);
    var dto = new DatarouterChangelogDtoBuilder("Nodewatch", clientName + "." + tableName, "deleted row samples", getSessionInfo().getNonEmptyUsernameOrElse("")).build();
    changelogRecorder.record(dto);
    return new InContextRedirectMav(request, paths.datarouter.nodewatch.tableCount.toSlashedString());
}
Also used : InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) TableSampleKey(io.datarouter.nodewatch.storage.tablesample.TableSampleKey) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 2 with DatarouterChangelogDtoBuilder

use of io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder in project datarouter by hotpads.

the class TableCountHandler method resample.

@Handler
private Mav resample(String clientName, String tableName) {
    var node = (PhysicalSortedStorageReaderNode<?, ?, ?>) nodes.getPhysicalNodeForClientAndTable(clientName, tableName);
    tableSpanSamplerJobletCreatorFactory.create(node, tableSamplerService.getSampleInterval(node), tableSamplerService.getBatchSize(node), true, true, System.currentTimeMillis()).createJoblets();
    var dto = new DatarouterChangelogDtoBuilder("Nodewatch", clientName + "." + tableName, "resample", getSessionInfo().getNonEmptyUsernameOrElse("")).build();
    changelogRecorder.record(dto);
    return new InContextRedirectMav(request, paths.datarouter.nodewatch.tableCount.toSlashedString() + "?submitAction=singleTable&clientName=" + clientName + "&tableName=" + tableName);
}
Also used : PhysicalSortedStorageReaderNode(io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 3 with DatarouterChangelogDtoBuilder

use of io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder in project datarouter by hotpads.

the class DatarouterUserHistoryService method putAndRecordEdit.

public void putAndRecordEdit(DatarouterUser user, DatarouterUser editor, String changes, String signinUrl) {
    var history = new DatarouterUserHistory(user.getId(), Instant.now(), editor.getId(), DatarouterUserChangeType.EDIT, changes);
    doPutAndRecordEdit(user, history);
    sendRoleEditEmail(user, history, signinUrl);
    DatarouterChangelogDto dto = new DatarouterChangelogDtoBuilder(CHANGELOG_TYPE, user.getUsername(), DatarouterUserChangeType.EDIT.getPersistentString(), editor.getUsername()).withComment(changes).build();
    changelogRecorder.record(dto);
}
Also used : DatarouterUserHistory(io.datarouter.auth.storage.userhistory.DatarouterUserHistory) DatarouterChangelogDto(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDto) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)

Example 4 with DatarouterChangelogDtoBuilder

use of io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder in project datarouter by hotpads.

the class DatarouterUserHistoryService method putAndRecordPasswordChange.

public void putAndRecordPasswordChange(DatarouterUser user, DatarouterUser editor, String signinUrl) {
    var history = new DatarouterUserHistory(user.getId(), Instant.now(), editor.getId(), DatarouterUserChangeType.RESET, "password");
    doPutAndRecordEdit(user, history);
    sendPasswordChangeEmail(user, history, signinUrl);
    DatarouterChangelogDto dto = new DatarouterChangelogDtoBuilder(CHANGELOG_TYPE, user.getUsername(), DatarouterUserChangeType.RESET.getPersistentString(), editor.getUsername()).build();
    changelogRecorder.record(dto);
}
Also used : DatarouterUserHistory(io.datarouter.auth.storage.userhistory.DatarouterUserHistory) DatarouterChangelogDto(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDto) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)

Example 5 with DatarouterChangelogDtoBuilder

use of io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder in project datarouter by hotpads.

the class JobStopperService method stopLocalJob.

// TODO licenses
private void stopLocalJob(String jobClassString, String username, Instant jobTriggerDeadline) {
    Class<? extends BaseJob> jobClass = BaseJob.parseClass(jobClassString);
    JobWrapper jobWrapper = localTriggerLockService.getForClass(jobClass);
    // job isn't running anymore
    if (jobWrapper == null) {
        return;
    }
    // the currently running job is not the one that the request was for
    if (jobWrapper.triggerTime.isAfter(jobTriggerDeadline)) {
        return;
    }
    jobWrapper.requestStop();
    // wait for job to gracefully stop itself
    ThreadTool.sleepUnchecked(JobScheduler.JOB_STOP_GRACE_PERIOD_MS);
    Future<Void> future = jobWrapper.getFuture();
    if (!future.isDone()) {
        future.cancel(true);
    }
    changelogRecorder.record(new DatarouterChangelogDtoBuilder("Job", jobClassString, "interrupt", username).build());
}
Also used : JobWrapper(io.datarouter.job.scheduler.JobWrapper) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)

Aggregations

DatarouterChangelogDtoBuilder (io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)26 BaseHandler (io.datarouter.web.handler.BaseHandler)15 OptionalString (io.datarouter.web.handler.types.optional.OptionalString)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 AmazonSQS (com.amazonaws.services.sqs.AmazonSQS)3 DatarouterUserHistory (io.datarouter.auth.storage.userhistory.DatarouterUserHistory)3 ChangelogRecorder (io.datarouter.instrumentation.changelog.ChangelogRecorder)3 JobletStatus (io.datarouter.joblet.enums.JobletStatus)3 JobletRequest (io.datarouter.joblet.storage.jobletrequest.JobletRequest)3 JobletRequestQueueKey (io.datarouter.joblet.storage.jobletrequestqueue.JobletRequestQueueKey)3 JobletType (io.datarouter.joblet.type.JobletType)3 TableSampleKey (io.datarouter.nodewatch.storage.tablesample.TableSampleKey)3 ClientId (io.datarouter.storage.client.ClientId)3 Mav (io.datarouter.web.handler.mav.Mav)3 Param (io.datarouter.web.handler.types.Param)3 Duration (java.time.Duration)3 Inject (javax.inject.Inject)3 GetQueueUrlResult (com.amazonaws.services.sqs.model.GetQueueUrlResult)2 DatarouterChangelogDto (io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDto)2