private WMFullResourcePlan createRP(String name, Integer parallelism, String defaultPoolPath) { WMResourcePlan rp = new WMResourcePlan(name); rp.setStatus(WMResourcePlanStatus.ACTIVE); if (parallelism != null) { rp.setQueryParallelism(parallelism); } if (defaultPoolPath != null) { rp.setDefaultPoolPath(defaultPoolPath); } WMFullResourcePlan fullRp = new WMFullResourcePlan(rp, new ArrayList<>()); return fullRp; }
public void showResourcePlans(DataOutputStream out, List<WMResourcePlan> resourcePlans) throws HiveException { try { for (WMResourcePlan plan : resourcePlans) { out.write(plan.getName().getBytes(UTF_8)); out.write(separator); out.write(plan.getStatus().name().getBytes(UTF_8)); out.write(separator); if (plan.isSetQueryParallelism()) { out.write(Integer.toString(plan.getQueryParallelism()).getBytes(UTF_8)); } else { write(out, "null"); } out.write(separator); if (plan.isSetDefaultPoolPath()) { out.write(plan.getDefaultPoolPath().getBytes(UTF_8)); } else { write(out, "null"); } out.write(terminator); } } catch (IOException e) { throw new HiveException(e); } }
public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case STATUS: return getStatus(); case QUERY_PARALLELISM: return getQueryParallelism(); case DEFAULT_POOL_PATH: return getDefaultPoolPath(); case NS: return getNs(); } throw new IllegalStateException(); }
public CreateResourcePlanDesc(String planName, Integer queryParallelism, String copyFromName, boolean ifNotExists) { resourcePlan = new WMResourcePlan(planName); if (queryParallelism != null) { resourcePlan.setQueryParallelism(queryParallelism); } this.copyFromName = copyFromName; this.ifNotExists = ifNotExists; }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case NAME: return isSetName(); case STATUS: return isSetStatus(); case QUERY_PARALLELISM: return isSetQueryParallelism(); case DEFAULT_POOL_PATH: return isSetDefaultPoolPath(); case NS: return isSetNs(); } throw new IllegalStateException(); }
case NAME: if (value == null) { unsetName(); } else { setName((String)value); unsetStatus(); } else { setStatus((WMResourcePlanStatus)value); unsetQueryParallelism(); } else { setQueryParallelism((Integer)value); unsetDefaultPoolPath(); } else { setDefaultPoolPath((String)value); unsetNs(); } else { setNs((String)value);
@Override public void read(org.apache.thrift.protocol.TProtocol prot, WMCreateResourcePlanRequest struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; BitSet incoming = iprot.readBitSet(2); if (incoming.get(0)) { struct.resourcePlan = new WMResourcePlan(); struct.resourcePlan.read(iprot); struct.setResourcePlanIsSet(true); } if (incoming.get(1)) { struct.copyFrom = iprot.readString(); struct.setCopyFromIsSet(true); } } }
private WMFullResourcePlan createTestResourcePlan() { WMFullResourcePlan resourcePlan; WMPool pool = new WMPool("testDefault", "llap"); pool.setAllocFraction(1f); pool.setQueryParallelism(1); resourcePlan = new WMFullResourcePlan( new WMResourcePlan("testDefault"), Lists.newArrayList(pool)); resourcePlan.getPlan().setDefaultPoolPath("testDefault"); return resourcePlan; }
throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException { boolean commited = false; String rpName = normalizeIdentifier(resourcePlan.getName()); if (rpName.isEmpty()) { throw new InvalidObjectException("Resource name cannot be empty."); if (copyFromName == null) { Integer queryParallelism = null; if (resourcePlan.isSetQueryParallelism()) { queryParallelism = resourcePlan.getQueryParallelism(); if (queryParallelism <= 0) { throw new InvalidObjectException("Query parallelism should be positive."); rp = new MWMResourcePlan(rpName, null, Status.DISABLED); rp.setNs(resourcePlan.getNs()); try { openTransaction(); pm.makePersistent(rp); if (copyFromName != null) { String ns = getNsOrDefault(resourcePlan.getNs()); MWMResourcePlan copyFrom = getMWMResourcePlan(copyFromName, ns, false); if (copyFrom == null) {
public WMResourcePlan deepCopy() { return new WMResourcePlan(this); }
public void createResourcePlan(WMResourcePlan resourcePlan, String copyFromName, boolean ifNotExists) throws HiveException { String ns = conf.getVar(ConfVars.HIVE_SERVER2_WM_NAMESPACE); if (resourcePlan.isSetNs() && !ns.equals(resourcePlan.getNs())) { throw new HiveException("Cannot create a plan in a different NS; was " + resourcePlan.getNs() + ", configured " + ns); } resourcePlan.setNs(ns); try { getMSC().createResourcePlan(resourcePlan, copyFromName); } catch (AlreadyExistsException e) { if (!ifNotExists) { throw new HiveException(e, ErrorMsg.RESOURCE_PLAN_ALREADY_EXISTS, resourcePlan.getName()); } } catch (Exception e) { throw new HiveException(e); } }
throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException { boolean commited = false; String rpName = normalizeIdentifier(resourcePlan.getName()); if (rpName.isEmpty()) { throw new InvalidObjectException("Resource name cannot be empty."); if (copyFromName == null) { Integer queryParallelism = null; if (resourcePlan.isSetQueryParallelism()) { queryParallelism = resourcePlan.getQueryParallelism(); if (queryParallelism <= 0) { throw new InvalidObjectException("Query parallelism should be positive.");
@Override public void write(org.apache.thrift.protocol.TProtocol prot, WMResourcePlan struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeString(struct.name); BitSet optionals = new BitSet(); if (struct.isSetStatus()) { optionals.set(0); } if (struct.isSetQueryParallelism()) { optionals.set(1); } if (struct.isSetDefaultPoolPath()) { optionals.set(2); } oprot.writeBitSet(optionals, 3); if (struct.isSetStatus()) { oprot.writeI32(struct.status.getValue()); } if (struct.isSetQueryParallelism()) { oprot.writeI32(struct.queryParallelism); } if (struct.isSetDefaultPoolPath()) { oprot.writeString(struct.defaultPoolPath); } }
@Override public WMCreateResourcePlanResponse create_resource_plan(WMCreateResourcePlanRequest request) throws AlreadyExistsException, InvalidObjectException, MetaException, TException { int defaultPoolSize = MetastoreConf.getIntVar( conf, MetastoreConf.ConfVars.WM_DEFAULT_POOL_SIZE); WMResourcePlan plan = request.getResourcePlan(); if (defaultPoolSize > 0 && plan.isSetQueryParallelism()) { // If the default pool is not disabled, override the size with the specified parallelism. defaultPoolSize = plan.getQueryParallelism(); } try { getMS().createResourcePlan(plan, request.getCopyFrom(), defaultPoolSize); return new WMCreateResourcePlanResponse(); } catch (MetaException e) { LOG.error("Exception while trying to persist resource plan", e); throw e; } }
String name = null; if (isActivate) { name = appliedRp.getPlan().getName(); LOG.info("Activating a new resource plan " + name + ": " + appliedRp); } else {
MockQam qam = new MockQam(); WMFullResourcePlan plan = new WMFullResourcePlan(plan(), Lists.newArrayList(pool("A", 1, 1f))); plan.getPlan().setDefaultPoolPath("A"); final WorkloadManager wm = new WorkloadManagerForTest("test", conf, qam, plan); wm.start();
this.userPoolMapping = new UserPoolMapping(null, null); } else { this.rpName = plan.getPlan().getName(); this.defaultPool = plan.getPlan().getDefaultPoolPath(); this.userPoolMapping = new UserPoolMapping(plan.getMappings(), defaultPool);
if (fullRp.getPlan().isSetDefaultPoolPath() && fullRp.getPlan().getDefaultPoolPath().equals(path)) { curr.isDefault = true;
assert appliedRp == null || appliedRp.getPlan().getStatus() == WMResourcePlanStatus.ACTIVE;
return false; boolean this_present_name = true && this.isSetName(); boolean that_present_name = true && that.isSetName(); if (this_present_name || that_present_name) { if (!(this_present_name && that_present_name)) boolean this_present_status = true && this.isSetStatus(); boolean that_present_status = true && that.isSetStatus(); if (this_present_status || that_present_status) { if (!(this_present_status && that_present_status)) boolean this_present_queryParallelism = true && this.isSetQueryParallelism(); boolean that_present_queryParallelism = true && that.isSetQueryParallelism(); if (this_present_queryParallelism || that_present_queryParallelism) { if (!(this_present_queryParallelism && that_present_queryParallelism)) boolean this_present_defaultPoolPath = true && this.isSetDefaultPoolPath(); boolean that_present_defaultPoolPath = true && that.isSetDefaultPoolPath(); if (this_present_defaultPoolPath || that_present_defaultPoolPath) { if (!(this_present_defaultPoolPath && that_present_defaultPoolPath)) boolean this_present_ns = true && this.isSetNs(); boolean that_present_ns = true && that.isSetNs(); if (this_present_ns || that_present_ns) { if (!(this_present_ns && that_present_ns))