All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.hologres.client.impl.handler.SqlActionHandler Maven / Gradle / Ivy

There is a newer version: 2.5.5
Show newest version
/*
 * Copyright (c) 2022. Alibaba Group Holding Limited
 */

package com.alibaba.hologres.client.impl.handler;

import com.alibaba.hologres.client.HoloConfig;
import com.alibaba.hologres.client.exception.HoloClientException;
import com.alibaba.hologres.client.impl.ConnectionHolder;
import com.alibaba.hologres.client.impl.action.SqlAction;

/**
 * SqlAction处理类.
 */
public class SqlActionHandler extends ActionHandler {

	private static final String NAME = "sql";

	private final ConnectionHolder connectionHolder;

	public SqlActionHandler(ConnectionHolder connectionHolder, HoloConfig config) {
		super(config);
		this.connectionHolder = connectionHolder;
	}

	@Override
	public void handle(SqlAction action) {
		try {
			action.getFuture().complete(connectionHolder.retryExecute((conn) -> action.getHandler().apply(conn)));
		} catch (HoloClientException e) {
			action.getFuture().completeExceptionally(e);
		}
	}

	@Override
	public String getCostMsMetricName() {
		return NAME + METRIC_COST_MS;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy