Search in sources :

Example 16 with ClientId

use of io.datarouter.storage.client.ClientId in project datarouter by hotpads.

the class SqsUpdateQueueHandler method deleteQueue.

@Handler
private Mav deleteQueue(@Param(PARAM_clientName) String clientName, @Param(PARAM_queueName) String queueName, @Param(PARAM_referer) String referer) {
    ClientId clientId = datarouterClients.getClientId(clientName);
    AmazonSQS sqs = sqsClientManager.getAmazonSqs(clientId);
    GetQueueUrlResult queueUrlResult = sqs.getQueueUrl(queueName);
    sqs.deleteQueue(queueUrlResult.getQueueUrl());
    String message = "Deleted unreferenced SQS queue: " + queueName;
    var dto = new DatarouterChangelogDtoBuilder("Sqs", queueName, "deleteQueue", getSessionInfo().getRequiredSession().getUsername()).build();
    changelogRecorder.record(dto);
    return buildPage(referer, message);
}
Also used : ClientId(io.datarouter.storage.client.ClientId) AmazonSQS(com.amazonaws.services.sqs.AmazonSQS) GetQueueUrlResult(com.amazonaws.services.sqs.model.GetQueueUrlResult) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 17 with ClientId

use of io.datarouter.storage.client.ClientId in project datarouter by hotpads.

the class SqsQueuesLengthMonitoringJob method getQueueLengthAndSaveAsMetric.

private void getQueueLengthAndSaveAsMetric(BaseSqsNode<?, ?, ?> baseSqsNode) {
    Twin<String> queueUrlAndName = baseSqsNode.getQueueUrlAndName().get();
    String queueName = queueUrlAndName.getRight();
    ClientId clientId = baseSqsNode.getClientId();
    String queueUrl = queueUrlAndName.getLeft();
    String queueLengthString = sqsClientManager.getQueueAttribute(clientId, queueUrl, QueueAttributeName.ApproximateNumberOfMessages);
    long queueLength = Long.parseLong(queueLengthString);
    metrics.saveSqsQueueLength(queueName, queueLength);
}
Also used : ClientId(io.datarouter.storage.client.ClientId)

Example 18 with ClientId

use of io.datarouter.storage.client.ClientId in project datarouter by hotpads.

the class HBaseCompactionJob method run.

@Override
public void run(TaskTracker tracker) {
    for (ClientId clientId : compactionInfo.getManagedClientIds()) {
        Admin admin = hBaseClientManager.getAdmin(clientId);
        DrServerList servers = new DrServerList(admin);
        List<String> tableNames = nodes.getTableNamesForClient(clientId.getName());
        for (String tableName : tableNames) {
            if (tracker.heartbeat(numRegions.sum()).shouldStop()) {
                return;
            }
            try {
                compactTable(tracker, admin, servers, clientId, tableName);
            } catch (Exception e) {
                logger.warn("error compacting {}.{}", clientId, tableName, e);
            }
        }
    }
    logger.warn("numTables={}, numRegions={}, numMissingLoad={}, numAlreadyLocal={}, numTriggered={}", numTables, numRegions, numMissingLoad, numAlreadyLocal, numTriggered);
}
Also used : ClientId(io.datarouter.storage.client.ClientId) Admin(org.apache.hadoop.hbase.client.Admin) DrServerList(io.datarouter.client.hbase.cluster.DrServerList)

Example 19 with ClientId

use of io.datarouter.storage.client.ClientId in project datarouter by hotpads.

the class MysqlWebInspector method getC3P0Stats.

private ContainerTag<?> getC3P0Stats(ClientId clientId, DatarouterWebRequestParams<MysqlClientType> clientParams) {
    MysqlClientManager clientManager = injector.getInstance(clientParams.getClientType().getClientManagerClass());
    Optional<C3p0StatsDto> c3p0Stats = c3p0StatsService.getC3p0Stats().stream().filter(stats -> stats.clientName.equals(clientId.getName())).findAny();
    var totalConnections = c3p0Stats.map(stats -> stats.total).map(stats -> stats + "").orElse("");
    var busyConnections = c3p0Stats.map(stats -> stats.busy).map(stats -> stats + "").orElse("");
    return dl(dt("handles:"), dd(clientManager.getStats(clientId)), dt("total connection:"), dd(totalConnections), dt("busy connection:"), dd(busyConnections));
}
Also used : DatarouterWebRequestParamsFactory(io.datarouter.web.browse.dto.DatarouterWebRequestParamsFactory) TagCreator.dd(j2html.TagCreator.dd) ClientOptions(io.datarouter.storage.client.ClientOptions) TagCreator.dl(j2html.TagCreator.dl) Inject(javax.inject.Inject) HttpServletRequest(javax.servlet.http.HttpServletRequest) MessageMav(io.datarouter.web.handler.mav.imp.MessageMav) DatarouterWebRequireJsV2(io.datarouter.web.requirejs.DatarouterWebRequireJsV2) MysqlClientManager(io.datarouter.client.mysql.MysqlClientManager) DatarouterWebRequestParams(io.datarouter.web.browse.dto.DatarouterWebRequestParamsFactory.DatarouterWebRequestParams) TagCreator.dt(j2html.TagCreator.dt) Map(java.util.Map) ClientId(io.datarouter.storage.client.ClientId) Params(io.datarouter.web.handler.params.Params) DatarouterInjector(io.datarouter.inject.DatarouterInjector) DatarouterClientWebInspector(io.datarouter.web.browse.DatarouterClientWebInspector) MysqlClientType(io.datarouter.client.mysql.MysqlClientType) ClientOptionsBuilder(io.datarouter.storage.client.ClientOptionsBuilder) Mav(io.datarouter.web.handler.mav.Mav) ContainerTag(j2html.tags.ContainerTag) Optional(java.util.Optional) Bootstrap4PageFactory(io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory) TagCreator.div(j2html.TagCreator.div) C3p0StatsDto(io.datarouter.client.mysql.connection.C3p0StatsDto) C3p0StatsService(io.datarouter.client.mysql.connection.C3p0StatsService) MysqlClientManager(io.datarouter.client.mysql.MysqlClientManager) C3p0StatsDto(io.datarouter.client.mysql.connection.C3p0StatsDto)

Example 20 with ClientId

use of io.datarouter.storage.client.ClientId in project datarouter by hotpads.

the class Datarouter method register.

public <PK extends PrimaryKey<PK>, D extends Databean<PK, D>, F extends DatabeanFielder<PK, D>, N extends Node<PK, D, F>> N register(N node) {
    nodes.register(node);
    for (ClientId clientId : registerClientIds(node.getClientIds())) {
        ClientManager clientManager = clients.getClientManager(clientId);
        clientManager.doSchemaUpdate(node.getPhysicalNodesForClient(clientId.getName()));
    }
    return node;
}
Also used : ClientManager(io.datarouter.storage.client.ClientManager) ClientId(io.datarouter.storage.client.ClientId)

Aggregations

ClientId (io.datarouter.storage.client.ClientId)21 List (java.util.List)10 Inject (javax.inject.Inject)9 Scanner (io.datarouter.scanner.Scanner)7 BaseHandler (io.datarouter.web.handler.BaseHandler)7 TagCreator.div (j2html.TagCreator.div)6 ContainerTag (j2html.tags.ContainerTag)6 ArrayList (java.util.ArrayList)6 Optional (java.util.Optional)6 DatarouterChangelogDtoBuilder (io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)4 DatarouterClients (io.datarouter.storage.client.DatarouterClients)4 PhysicalNode (io.datarouter.storage.node.type.physical.PhysicalNode)4 Mav (io.datarouter.web.handler.mav.Mav)4 J2HtmlTable (io.datarouter.web.html.j2html.J2HtmlTable)4 Bootstrap4PageFactory (io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory)4 DatarouterWebRequireJsV2 (io.datarouter.web.requirejs.DatarouterWebRequireJsV2)4 Collections (java.util.Collections)4 Map (java.util.Map)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4