@Override public String getHostAddress() { return getRemoteAddr(); } @Override
@Override public InetAddress getHostInetAddress() { try { return InetAddress.getByName(getHostAddress()); } catch (UnknownHostException e) { return null; } } };
private <T> T doAs(final UserGroupInformation ugi, final PrivilegedExceptionAction<T> action) throws IOException, InterruptedException { return useIpcCallq ? doAsExternalCall(ugi, action) : ugi.doAs(action); }
final Param<?, ?>... parameters) throws URISyntaxException, IOException { final DatanodeInfo dn; final NamenodeProtocols np = getRPCServer(namenode); HdfsFileStatus status = null; if (op == GetOpParam.Op.OPEN status = np.getFileInfo(path); dn = chooseDatanode(namenode, path, op, openOffset, blocksize, excludeDatanodes, remoteAddr, status); if (dn == null) { } else { final Token<? extends TokenIdentifier> t = generateDelegationToken( namenode, ugi, null); delegationQuery = "&" + new DelegationParam(t.encodeToUrlString()); prependReservedRawPath = true; rb.header(WebHdfsFileSystem.FEFINFO_HEADER, encodeFeInfo(status.getFileEncryptionInfo()));
|| op == PostOpParam.Op.APPEND) { final NamenodeProtocols np = getRPCServer(namenode); if (status == null) { throw new FileNotFoundException("File " + path + " not found."); final int count = locations.locatedBlockCount(); if (count > 0) { return bestNode(locations.get(0).getLocations(), excludes);
@Override public Response run() throws IOException, URISyntaxException { return post(ugi, delegation, username, doAsUser, path.getAbsolutePath(), op, concatSrcs, bufferSize, excludeDatanodes, newLength, noredirect); } });
@Override public Response run() throws IOException { return delete(ugi, delegation, username, doAsUser, path.getAbsolutePath(), op, recursive, snapshotName); } });
@Override public Response run() throws IOException, URISyntaxException { return put(ugi, delegation, username, doAsUser, path.getAbsolutePath(), op, destination, owner, group, permission, unmaskedPermission, overwrite, bufferSize, replication, blockSize, modificationTime, accessTime, renameOptions, createParent, delegationTokenArgument, aclPermission, xattrName, xattrValue, xattrSetFlag, snapshotName, oldSnapshotName, excludeDatanodes, createFlagParam, noredirect, policyName); } });
final DirectoryListing firstDirList = getDirectoryListing(cp, p, HdfsFileStatus.EMPTY_NAME);
/** * Returns true if a WebHdfs request is in progress. Akin to * {@link Server#isRpcInvocation()}. */ public static boolean isWebHdfsInvocation() { return getRemoteAddress() != null; }
@Override public Response run() throws IOException, URISyntaxException { String absolutePath = path.getAbsolutePath() == null ? null : URLDecoder.decode(path.getAbsolutePath(), "UTF-8"); return get(ugi, delegation, username, doAsUser, absolutePath, op, offset, length, renewer, bufferSize, xattrNames, xattrEncoding, excludeDatanodes, fsAction, snapshotName, oldSnapshotName, tokenKind, tokenService, noredirect, startAfter); } });
private static InetAddress getRemoteIp() { InetAddress ip = Server.getRemoteIp(); if (ip != null) { return ip; } return NamenodeWebHdfsMethods.getRemoteIp(); }
/** * Client invoked methods are invoked over RPC and will be in * RPC call context even if the client exits. */ boolean isExternalInvocation() { return Server.isRpcInvocation() || NamenodeWebHdfsMethods.isWebHdfsInvocation(); }
queueExternalCall(call); T result = null; try {
/** Handle HTTP POST request for the root. */ @POST @Path("/") @Consumes({"*/*"}) @Produces({MediaType.APPLICATION_OCTET_STREAM + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8}) public Response postRoot( @Context final UserGroupInformation ugi, @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT) final DelegationParam delegation, @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT) final UserParam username, @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT) final DoAsParam doAsUser, @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT) final PostOpParam op, @QueryParam(ConcatSourcesParam.NAME) @DefaultValue(ConcatSourcesParam.DEFAULT) final ConcatSourcesParam concatSrcs, @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT) final BufferSizeParam bufferSize, @QueryParam(ExcludeDatanodesParam.NAME) @DefaultValue(ExcludeDatanodesParam.DEFAULT) final ExcludeDatanodesParam excludeDatanodes, @QueryParam(NewLengthParam.NAME) @DefaultValue(NewLengthParam.DEFAULT) final NewLengthParam newLength, @QueryParam(NoRedirectParam.NAME) @DefaultValue(NoRedirectParam.DEFAULT) final NoRedirectParam noredirect ) throws IOException, InterruptedException { return post(ugi, delegation, username, doAsUser, ROOT, op, concatSrcs, bufferSize, excludeDatanodes, newLength, noredirect); }
/** Handle HTTP DELETE request for the root. */ @DELETE @Path("/") @Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8) public Response deleteRoot( @Context final UserGroupInformation ugi, @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT) final DelegationParam delegation, @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT) final UserParam username, @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT) final DoAsParam doAsUser, @QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT) final DeleteOpParam op, @QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT) final RecursiveParam recursive, @QueryParam(SnapshotNameParam.NAME) @DefaultValue(SnapshotNameParam.DEFAULT) final SnapshotNameParam snapshotName ) throws IOException, InterruptedException { return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive, snapshotName); }
/** * Returns true if a WebHdfs request is in progress. Akin to * {@link Server#isRpcInvocation()}. */ public static boolean isWebHdfsInvocation() { return getRemoteAddress() != null; }
private static InetAddress getRemoteIp() { InetAddress ip = Server.getRemoteIp(); if (ip != null) { return ip; } return NamenodeWebHdfsMethods.getRemoteIp(); }
/** * Client invoked methods are invoked over RPC and will be in * RPC call context even if the client exits. */ boolean isExternalInvocation() { return Server.isRpcInvocation() || NamenodeWebHdfsMethods.isWebHdfsInvocation(); }
private static String getClientMachine() { String clientMachine = NamenodeWebHdfsMethods.getRemoteAddress(); if (clientMachine == null) { //not a web client clientMachine = Server.getRemoteAddress(); } if (clientMachine == null) { //not a RPC client clientMachine = ""; } return clientMachine; }