List of usage examples for org.apache.hadoop.yarn.factory.providers RecordFactoryProvider getRecordFactory
public static RecordFactory getRecordFactory(Configuration conf)
From source file:gobblin.hadoop.token.TokenUtils.java
License:Open Source License
private static Token<?> getDelegationTokenFromHS(HSClientProtocol hsProxy, Configuration conf) throws IOException, InterruptedException { GetDelegationTokenRequest request = RecordFactoryProvider.getRecordFactory(null) .newRecordInstance(GetDelegationTokenRequest.class); request.setRenewer(Master.getMasterPrincipal(conf)); org.apache.hadoop.yarn.api.records.Token mrDelegationToken; mrDelegationToken = hsProxy.getDelegationToken(request).getDelegationToken(); return ConverterUtils.convertFromYarn(mrDelegationToken, hsProxy.getConnectAddress()); }
From source file:gobblin.util.hadoop.TokenUtils.java
License:Apache License
private static Token<?> getDelegationTokenFromHS(HSClientProtocol hsProxy, Configuration conf) throws IOException { GetDelegationTokenRequest request = RecordFactoryProvider.getRecordFactory(null) .newRecordInstance(GetDelegationTokenRequest.class); request.setRenewer(Master.getMasterPrincipal(conf)); org.apache.hadoop.yarn.api.records.Token mrDelegationToken; mrDelegationToken = hsProxy.getDelegationToken(request).getDelegationToken(); return ConverterUtils.convertFromYarn(mrDelegationToken, hsProxy.getConnectAddress()); }
From source file:org.apache.oozie.action.hadoop.JHSCredentials.java
License:Apache License
/** * Get a Delegation token from the JHS./* w w w .ja v a2 s.c om*/ * Copied over from YARNRunner in Hadoop. * @param hsProxy protcol used to get the token * @return The RM_DELEGATION_TOKEN that can be used to talk to JHS * @throws IOException * @throws InterruptedException */ private Token<?> getDelegationTokenFromJHS(final MRClientProtocol hsProxy, final String renewer) throws IOException, InterruptedException { GetDelegationTokenRequest request = RecordFactoryProvider.getRecordFactory(null) .newRecordInstance(GetDelegationTokenRequest.class); LOG.debug("Creating requsest to JHS using renewer [{0}]", renewer); request.setRenewer(renewer); org.apache.hadoop.yarn.api.records.Token mrDelegationToken = hsProxy.getDelegationToken(request) .getDelegationToken(); LOG.debug("Got token to JHS : {0}. Converting token.", mrDelegationToken); return ConverterUtils.convertFromYarn(mrDelegationToken, hsProxy.getConnectAddress()); }
From source file:org.apache.tajo.worker.TaskRunnerTest.java
License:Apache License
public void testInit() throws Exception { ProtoAsyncRpcClient mockClient = mock(ProtoAsyncRpcClient.class); mockClient.close();/*from www . j av a 2 s . c o m*/ MasterWorkerProtocolService.Interface mockMaster = mock(MasterWorkerProtocolService.Interface.class); ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(q1.getApplicationId(), q1.getAttemptId()); ContainerId cId = BuilderUtils.newContainerId(appAttemptId, 1); NodeId nodeId = RecordFactoryProvider.getRecordFactory(null).newRecordInstance(NodeId.class); nodeId.setHost("host1"); nodeId.setPort(9001); UserGroupInformation mockTaskOwner = mock(UserGroupInformation.class); when(mockTaskOwner.getShortUserName()).thenReturn("hyunsik"); TaskRunner runner = new TaskRunner(sq1, nodeId, mockTaskOwner, mockMaster, cId); QueryConf conf = new QueryConf(); conf.setOutputPath(new Path("/tmp/" + q1)); runner.init(conf); runner.start(); runner.stop(); }
From source file:org.apache.tez.dag.app.launcher.TestTezLocalCacheManager.java
License:Apache License
private static LocalResource createFile(String content) throws IOException { FileContext fs = FileContext.getLocalFSFileContext(); java.nio.file.Path tempFile = Files.createTempFile("test-cache-manager", ".txt"); File temp = tempFile.toFile(); temp.deleteOnExit();/*from ww w . j av a2 s .c o m*/ Path p = new Path("file:///" + tempFile.toAbsolutePath().toString()); Files.write(tempFile, content.getBytes()); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); LocalResource ret = recordFactory.newRecordInstance(LocalResource.class); URL yarnUrlFromPath = ConverterUtils.getYarnUrlFromPath(p); ret.setResource(yarnUrlFromPath); ret.setSize(content.getBytes().length); ret.setType(LocalResourceType.FILE); ret.setVisibility(LocalResourceVisibility.PRIVATE); ret.setTimestamp(fs.getFileStatus(p).getModificationTime()); return ret; }
From source file:org.huahinframework.manager.rest.service.ApplicationService.java
License:Apache License
/** * init/*from w ww . j a v a 2 s.c o m*/ */ public void init() { YarnRPC rpc = YarnRPC.create(getJobConf()); YarnConfiguration yarnConf = new YarnConfiguration(getJobConf()); InetSocketAddress rmAddress = NetUtils .createSocketAddr(yarnConf.get(YarnConfiguration.RM_ADDRESS, YarnConfiguration.DEFAULT_RM_ADDRESS)); applicationsManager = ((ClientRMProtocol) rpc.getProxy(ClientRMProtocol.class, rmAddress, yarnConf)); recordFactory = RecordFactoryProvider.getRecordFactory(yarnConf); }