@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { if (StringUtils.isBlank(driverType) || StringUtils.isBlank(driverName)) { throw new LensException("Driver Type and Name can not be null or empty"); } fullyQualifiedName = driverType + SEPARATOR + driverName; this.conf = new DriverConfiguration(conf, driverType, getClass()); this.conf.addResource(getClass().getSimpleName().toLowerCase() + "-default.xml"); this.conf.addResource(getDriverResourcePath(getClass().getSimpleName().toLowerCase() + "-site.xml")); this.queryConstraints = getImplementations(QUERY_LAUNCHING_CONSTRAINT_FACTORIES_SFX, getConf()); this.waitingQuerySelectionPolicies = getImplementations(WAITING_QUERIES_SELECTION_POLICY_FACTORIES_SFX, getConf()); loadRetryPolicyDecider(); loadQueryHook(); }
/** * Gets the path (relative to lens server's conf location) for the driver resource in the system. This is a utility * method that can be used by extending driver implementations to build path for their resources. * * @param resourceName * @return */ protected String getDriverResourcePath(String resourceName) { return LensConfConstants.DRIVERS_BASE_DIR + SEPARATOR + getFullyQualifiedName() + SEPARATOR + resourceName; }
@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { super.configure(conf, driverType, driverName); init(); configured = true; log.info("JDBC Driver {} configured", getFullyQualifiedName()); }
protected void loadRetryPolicyDecider() throws LensException { this.retryPolicyDecider = ChainedRetryPolicyDecider.from(getConf(), RETRY_POLICY_CLASSES_SFX); }
/** * Default implementation for fetchResultSet for all drivers. Should hold good in most cases. * Note : If a driver is sticking to this default implementation, it should * override {@link #createResultSet(QueryContext)} */ @Override public LensResultSet fetchResultSet(QueryContext ctx) throws LensException { log.info("FetchResultSet: {}", ctx.getQueryHandle()); if (!ctx.getDriverStatus().isSuccessful()) { throw new LensException("Can't fetch results for a " + ctx.getQueryHandleString() + " because it's status is " + ctx.getStatus()); } ctx.registerDriverResult(createResultSet(ctx)); // registerDriverResult makes sure registration happens ony once return ctx.getDriverResult(); }
@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { super.configure(conf, driverType, driverName); init(); configured = true; Class<? extends QueryCostCalculator> queryCostCalculatorClass = getConf().getClass(JDBC_COST_CALCULATOR, StaticCostCalculator.class, QueryCostCalculator.class); try { queryCostCalculator = queryCostCalculatorClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new LensException("Can't instantiate query cost calculator of class: " + queryCostCalculatorClass, e); } //For initializing the decider class instance queryCostCalculator.init(this); log.info("JDBC Driver {} configured", getFullyQualifiedName()); }
protected void loadRetryPolicyDecider() throws LensException { this.retryPolicyDecider = ChainedRetryPolicyDecider.from(getConf(), RETRY_POLICY_CLASSES_SFX); }
/** * Default implementation for fetchResultSet for all drivers. Should hold good in most cases. * Note : If a driver is sticking to this default implementation, it should * override {@link #createResultSet(QueryContext)} */ @Override public LensResultSet fetchResultSet(QueryContext ctx) throws LensException { log.info("FetchResultSet: {}", ctx.getQueryHandle()); if (!ctx.getDriverStatus().isSuccessful()) { throw new LensException("Can't fetch results for a " + ctx.getQueryHandleString() + " because it's status is " + ctx.getStatus()); } ctx.registerDriverResult(createResultSet(ctx)); // registerDriverResult makes sure registration happens ony once return ctx.getDriverResult(); }
@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { super.configure(conf, driverType, driverName); config = new ESDriverConfig(getConf()); Class klass;
@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { if (StringUtils.isBlank(driverType) || StringUtils.isBlank(driverName)) { throw new LensException("Driver Type and Name can not be null or empty"); } fullyQualifiedName = driverType + SEPARATOR + driverName; this.conf = new DriverConfiguration(conf, driverType, getClass()); this.conf.addResource(getClass().getSimpleName().toLowerCase() + "-default.xml"); this.conf.addResource(getDriverResourcePath(getClass().getSimpleName().toLowerCase() + "-site.xml")); this.queryConstraints = getImplementations(QUERY_LAUNCHING_CONSTRAINT_FACTORIES_SFX, getConf()); this.waitingQuerySelectionPolicies = getImplementations(WAITING_QUERIES_SELECTION_POLICY_FACTORIES_SFX, getConf()); loadRetryPolicyDecider(); loadQueryHook(); }
/** * Gets the path (relative to lens server's conf location) for the driver resource in the system. This is a utility * method that can be used by extending driver implementations to build path for their resources. * * @param resourceName * @return */ protected String getDriverResourcePath(String resourceName) { return LensConfConstants.DRIVERS_BASE_DIR + SEPARATOR + getFullyQualifiedName() + SEPARATOR + resourceName; }
protected void loadQueryHook() throws LensException { this.queryHook = ChainedDriverQueryHook.from(getConf(), DRIVER_HOOK_CLASSES_SFX); queryHook.setDriver(this); }
@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { super.configure(conf, driverType, driverName); config = new ESDriverConfig(getConf()); Class klass;
@Override public String toString() { return getFullyQualifiedName(); } }
protected void loadQueryHook() throws LensException { this.queryHook = ChainedDriverQueryHook.from(getConf(), DRIVER_HOOK_CLASSES_SFX); queryHook.setDriver(this); }
@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { super.configure(conf, driverType, driverName); this.hiveConf = new HiveConf(conf, HiveDriver.class); this.hiveConf.addResource(getConf()); connectionClass = getConf().getClass(HIVE_CONNECTION_CLASS, EmbeddedThriftConnection.class, ThriftConnection.class); isEmbedded = (connectionClass.getName().equals(EmbeddedThriftConnection.class.getName())); connectionExpiryTimeout = getConf().getLong(HS2_CONNECTION_EXPIRY_DELAY, DEFAULT_EXPIRY_DELAY); whetherCalculatePriority = getConf().getBoolean(HS2_CALCULATE_PRIORITY, true); Class<? extends QueryCostCalculator> queryCostCalculatorClass = getConf().getClass(HS2_COST_CALCULATOR, FactPartitionBasedQueryCostCalculator.class, QueryCostCalculator.class); try { queryCostCalculator = queryCostCalculatorClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new LensException("Can't instantiate query cost calculator of class: " + queryCostCalculatorClass, e); } queryPriorityDecider = new CostRangePriorityDecider( new CostToPriorityRangeConf(getConf().get(HS2_PRIORITY_RANGES, HS2_PRIORITY_DEFAULT_RANGES)) ); log.info("Hive driver {} configured successfully", getFullyQualifiedName()); }
@Override public String toString() { return getFullyQualifiedName(); } }
@Override public void configure(Configuration conf, String driverType, String driverName) throws LensException { super.configure(conf, driverType, driverName);