private void print(String fragmentFile, int bitCount, int expectedFragmentCount) throws Exception{ System.out.println(String.format("=================Building plan fragments for [%s]. Allowing %d total Nodes.==================", fragmentFile, bitCount)); PhysicalPlanReader ppr = PhysicalPlanReaderTestFactory.defaultPhysicalPlanReader(DEFAULT_SABOT_CONFIG, CLASSPATH_SCAN_RESULT); Fragment fragmentRoot = getRootFragment(ppr, fragmentFile); SimpleParallelizer par = new SimpleParallelizer(1000*1000, 5, 10, 1.2, AbstractAttemptObserver.NOOP, true, 1.5d); List<NodeEndpoint> endpoints = Lists.newArrayList(); NodeEndpoint localBit = null; for(int i =0; i < bitCount; i++) { NodeEndpoint b1 = NodeEndpoint.newBuilder().setAddress("localhost").setFabricPort(1234+i).build(); if (i == 0) { localBit = b1; } endpoints.add(b1); } final QueryContextInformation queryContextInfo = Utilities.createQueryContextInfo("dummySchemaName"); List<PlanFragment> qwu = par.getFragments(new OptionList(), localBit, QueryId.getDefaultInstance(), endpoints, ppr, fragmentRoot, UserSession.Builder.newBuilder().withCredentials(UserBitShared.UserCredentials.newBuilder().setUserName("foo").build()).build(), queryContextInfo, null); assertEquals(expectedFragmentCount, qwu.size() + 1 /* root fragment is not part of the getFragments() list*/); }
subBuilder.mergeFrom(credentials_); credentials_ = subBuilder.buildPartial();
subBuilder.mergeFrom(credentials_); credentials_ = subBuilder.buildPartial();
.setUserName("foo") .build()) .withUserProperties(UserProperties.getDefaultInstance()) .withOptionManager(nodeContext1.getOptionManager())
.withCredentials(UserBitShared.UserCredentials.newBuilder().setUserName("foo").build()) .withUserProperties(UserProperties.getDefaultInstance()) .withOptionManager(nodeContext1.getOptionManager())
.setUserName(username) .build()) .withUserProperties(UserProtos.UserProperties.getDefaultInstance()) .withOptionManager(sabotContext.getOptionManager())
@Override public void submitLocalQuery( ExternalId externalId, QueryObserver observer, Object query, boolean prepare, LocalExecutionConfig config) { try{ // make sure we keep a local observer out of band. final QueryObserver oobJobObserver = new OutOfBandQueryObserver(observer, executor); UserSession session = UserSession.Builder.newBuilder() .setSupportComplexTypes(true) .withCredentials(UserCredentials .newBuilder() .setUserName(config.getUsername()) .build()) .exposeInternalSources(config.isExposingInternalSources()) .withDefaultSchema(config.getSqlContext()) .withSubstitutionSettings(config.getSubstitutionSettings()) .withOptionManager(options) .withClientInfos(UserRpcUtils.getRpcEndpointInfos("Dremio Java local client")) .build(); final ReAttemptHandler attemptHandler = newInternalAttemptHandler(options, config.isFailIfNonEmptySent()); submit(externalId, oobJobObserver, session, new UserRequest(prepare ? RpcType.CREATE_PREPARED_STATEMENT : RpcType.RUN_QUERY, query), TerminationListenerRegistry.NOOP, config, attemptHandler); }catch(Exception ex){ throw Throwables.propagate(ex); } } }
/** * <code>optional .exec.shared.UserCredentials credentials = 14;</code> */ public Builder mergeCredentials(com.dremio.exec.proto.UserBitShared.UserCredentials value) { if (credentialsBuilder_ == null) { if (((bitField0_ & 0x00000800) == 0x00000800) && credentials_ != com.dremio.exec.proto.UserBitShared.UserCredentials.getDefaultInstance()) { credentials_ = com.dremio.exec.proto.UserBitShared.UserCredentials.newBuilder(credentials_).mergeFrom(value).buildPartial(); } else { credentials_ = value; } onChanged(); } else { credentialsBuilder_.mergeFrom(value); } bitField0_ |= 0x00000800; return this; } /**
/** * <code>optional .exec.shared.UserCredentials credentials = 4;</code> */ public Builder mergeCredentials(com.dremio.exec.proto.UserBitShared.UserCredentials value) { if (credentialsBuilder_ == null) { if (((bitField0_ & 0x00000008) == 0x00000008) && credentials_ != com.dremio.exec.proto.UserBitShared.UserCredentials.getDefaultInstance()) { credentials_ = com.dremio.exec.proto.UserBitShared.UserCredentials.newBuilder(credentials_).mergeFrom(value).buildPartial(); } else { credentials_ = value; } onChanged(); } else { credentialsBuilder_.mergeFrom(value); } bitField0_ |= 0x00000008; return this; } /**
public void mergeFrom(io.protostuff.Input input, com.dremio.exec.proto.UserBitShared.UserCredentials.Builder builder) throws java.io.IOException { for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) { switch(number) { case 0: return; case 1: builder.setUserName(input.readString()); break; default: input.handleUnknownField(number, this); } } } public boolean isInitialized(com.dremio.exec.proto.UserBitShared.UserCredentials.Builder builder)
/** * <code>optional .exec.shared.UserCredentials credentials = 14;</code> */ public Builder setCredentials( com.dremio.exec.proto.UserBitShared.UserCredentials.Builder builderForValue) { if (credentialsBuilder_ == null) { credentials_ = builderForValue.build(); onChanged(); } else { credentialsBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000800; return this; } /**
/** * <code>optional .exec.shared.UserCredentials credentials = 4;</code> */ public Builder setCredentials( com.dremio.exec.proto.UserBitShared.UserCredentials.Builder builderForValue) { if (credentialsBuilder_ == null) { credentials_ = builderForValue.build(); onChanged(); } else { credentialsBuilder_.setMessage(builderForValue.build()); } bitField0_ |= 0x00000008; return this; } /**
private static Builder create() { return new Builder(); }
public Builder clone() { return create().mergeFrom(buildPartial()); }
private UserBitShared.UserCredentials getUserCredentials() { // If username is not propagated as one of the properties String userName = "anonymous"; if (props != null) { for (Property property: props.getPropertiesList()) { if (property.getKey().equalsIgnoreCase("user") && !Strings.isNullOrEmpty(property.getValue())) { userName = property.getValue(); break; } } } return UserBitShared.UserCredentials.newBuilder().setUserName(userName).build(); }
private QueryContext newQueryContext(SqlQuery query) { try (TimedBlock b = time("initParser")) { QueryId queryId = QueryId.newBuilder().setPart1(ID_MAJOR).setPart2(ID_MINOR.incrementAndGet()).build(); UserSession session = UserSession.Builder.newBuilder() .withCredentials(UserCredentials.newBuilder() .setUserName(query.getUsername()) .build()) .withUserProperties(UserProperties.getDefaultInstance()) .withOptionManager(sabotContext.getOptionManager()) .build(); return new QueryContext(session, sabotContext, queryId); } }
public boolean isInitialized(com.dremio.exec.proto.UserBitShared.UserCredentials.Builder builder) { return builder.isInitialized(); } public com.dremio.exec.proto.UserBitShared.UserCredentials.Builder newMessage()
public static UserSession session() { return UserSession.Builder.newBuilder() .withUserProperties(UserProtos.UserProperties.getDefaultInstance()) .withCredentials(UserBitShared.UserCredentials.newBuilder().setUserName("foo").build()) .withOptionManager(getSabotContext().getOptionManager()) .setSupportComplexTypes(true) .build(); }
@java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessage.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /**
private static UserSession session() { return UserSession.Builder.newBuilder() .withUserProperties(UserProtos.UserProperties.getDefaultInstance()) .withCredentials(UserBitShared.UserCredentials.newBuilder().setUserName("foo").build()) .withOptionManager(getSabotContext().getOptionManager()) .setSupportComplexTypes(true) .build(); } }