public static void writeCacheDirectiveInfo(ContentHandler contentHandler, CacheDirectiveInfo directive) throws SAXException { XMLUtils.addSaxString(contentHandler, "ID", Long.toString(directive.getId())); if (directive.getPath() != null) { XMLUtils.addSaxString(contentHandler, "PATH", directive.getPath().toUri().getPath()); } if (directive.getReplication() != null) { XMLUtils.addSaxString(contentHandler, "REPLICATION", Short.toString(directive.getReplication())); } if (directive.getPool() != null) { XMLUtils.addSaxString(contentHandler, "POOL", directive.getPool()); } if (directive.getExpiration() != null) { XMLUtils.addSaxString(contentHandler, "EXPIRATION", "" + directive.getExpiration().getMillis()); } }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "INODEID", Long.toString(inodeId)); XMLUtils.addSaxString(contentHandler, "PATH", path); XMLUtils.addSaxString(contentHandler, "TIMESTAMP", Long.toString(timestamp)); FSEditLogOp.permissionStatusToXml(contentHandler, permissions); if (aclEntries != null) { appendAclEntriesToXml(contentHandler, aclEntries); } if (xAttrs != null) { appendXAttrsToXml(contentHandler, xAttrs); } }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "SRC", src); XMLUtils.addSaxString(contentHandler, "DST", dst); XMLUtils.addSaxString(contentHandler, "TIMESTAMP", Long.toString(timestamp)); StringBuilder bld = new StringBuilder(); String prefix = ""; for (Rename r : options) { bld.append(prefix).append(r.toString()); prefix = "|"; } XMLUtils.addSaxString(contentHandler, "OPTIONS", bld.toString()); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
public static void delegationTokenToXml(ContentHandler contentHandler, DelegationTokenIdentifier token) throws SAXException { contentHandler.startElement("", "", "DELEGATION_TOKEN_IDENTIFIER", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "KIND", token.getKind().toString()); XMLUtils.addSaxString(contentHandler, "SEQUENCE_NUMBER", Integer.toString(token.getSequenceNumber())); XMLUtils.addSaxString(contentHandler, "OWNER", token.getOwner().toString()); XMLUtils.addSaxString(contentHandler, "RENEWER", token.getRenewer().toString()); XMLUtils.addSaxString(contentHandler, "REALUSER", token.getRealUser().toString()); XMLUtils.addSaxString(contentHandler, "ISSUE_DATE", Long.toString(token.getIssueDate())); XMLUtils.addSaxString(contentHandler, "MAX_DATE", Long.toString(token.getMaxDate())); XMLUtils.addSaxString(contentHandler, "MASTER_KEY_ID", Integer.toString(token.getMasterKeyId())); contentHandler.endElement("", "", "DELEGATION_TOKEN_IDENTIFIER"); }
private static void appendXAttrsToXml(ContentHandler contentHandler, List<XAttr> xAttrs) throws SAXException { for (XAttr xAttr: xAttrs) { contentHandler.startElement("", "", "XATTR", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "NAMESPACE", xAttr.getNameSpace().toString()); XMLUtils.addSaxString(contentHandler, "NAME", xAttr.getName()); if (xAttr.getValue() != null) { try { XMLUtils.addSaxString(contentHandler, "VALUE", XAttrCodec.encodeValue(xAttr.getValue(), XAttrCodec.HEX)); } catch (IOException e) { throw new SAXException(e); } } contentHandler.endElement("", "", "XATTR"); } }
/** * Finish visitor */ @Override public void close(Throwable error) throws IOException { try { contentHandler.endElement("", "", "EDITS"); if (error != null) { String msg = error.getMessage(); XMLUtils.addSaxString(contentHandler, "ERROR", (msg == null) ? "null" : msg); } contentHandler.endDocument(); } catch (SAXException e) { throw new IOException("SAX error: " + e.getMessage()); } out.close(); }
public static void writeCachePoolInfo(ContentHandler contentHandler, CachePoolInfo info) throws SAXException { XMLUtils.addSaxString(contentHandler, "POOLNAME", info.getPoolName()); final String ownerName = info.getOwnerName(); final String groupName = info.getGroupName(); final Long limit = info.getLimit(); final FsPermission mode = info.getMode(); final Long maxRelativeExpiry = info.getMaxRelativeExpiryMs(); if (ownerName != null) { XMLUtils.addSaxString(contentHandler, "OWNERNAME", ownerName); } if (groupName != null) { XMLUtils.addSaxString(contentHandler, "GROUPNAME", groupName); } if (mode != null) { FSEditLogOp.fsPermissionToXml(contentHandler, mode); } if (limit != null) { XMLUtils.addSaxString(contentHandler, "LIMIT", Long.toString(limit)); } if (maxRelativeExpiry != null) { XMLUtils.addSaxString(contentHandler, "MAXRELATIVEEXPIRY", Long.toString(maxRelativeExpiry)); } }
private static void appendRpcIdsToXml(ContentHandler contentHandler, final byte[] clientId, final int callId) throws SAXException { XMLUtils.addSaxString(contentHandler, "RPC_CLIENTID", ClientId.toString(clientId)); XMLUtils.addSaxString(contentHandler, "RPC_CALLID", Integer.toString(callId)); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "INODEID", Long.toString(inodeId)); XMLUtils.addSaxString(contentHandler, "PATH", path); XMLUtils.addSaxString(contentHandler, "REPLICATION", Short.valueOf(replication).toString()); XMLUtils.addSaxString(contentHandler, "MTIME", Long.toString(mtime)); XMLUtils.addSaxString(contentHandler, "ATIME", Long.toString(atime)); XMLUtils.addSaxString(contentHandler, "BLOCKSIZE", Long.toString(blockSize)); XMLUtils.addSaxString(contentHandler, "CLIENT_NAME", clientName); XMLUtils.addSaxString(contentHandler, "CLIENT_MACHINE", clientMachine); XMLUtils.addSaxString(contentHandler, "OVERWRITE", Boolean.toString(overwrite)); for (Block b : blocks) { FSEditLogOp.blockToXml(contentHandler, b); } FSEditLogOp.permissionStatusToXml(contentHandler, permissions); if (this.opCode == OP_ADD) { if (aclEntries != null) { appendAclEntriesToXml(contentHandler, aclEntries); } appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); } }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "PATH", path); XMLUtils.addSaxString(contentHandler, "CLIENT_NAME", clientName); XMLUtils.addSaxString(contentHandler, "CLIENT_MACHINE", clientMachine); XMLUtils.addSaxString(contentHandler, "NEWBLOCK", Boolean.toString(newBlock)); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "PATH", path); if (penultimateBlock != null) { FSEditLogOp.blockToXml(contentHandler, penultimateBlock); } FSEditLogOp.blockToXml(contentHandler, lastBlock); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "PATH", path); for (Block b : blocks) { FSEditLogOp.blockToXml(contentHandler, b); } appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "TRG", trg); XMLUtils.addSaxString(contentHandler, "TIMESTAMP", Long.toString(timestamp)); contentHandler.startElement("", "", "SOURCES", new AttributesImpl()); for (int i = 0; i < srcs.length; ++i) { XMLUtils.addSaxString(contentHandler, "SOURCE" + (i + 1), srcs[i]); } contentHandler.endElement("", "", "SOURCES"); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "SRC", src); XMLUtils.addSaxString(contentHandler, "DST", dst); XMLUtils.addSaxString(contentHandler, "TIMESTAMP", Long.toString(timestamp)); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "PATH", path); XMLUtils.addSaxString(contentHandler, "TIMESTAMP", Long.toString(timestamp)); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "SRC", src); if (username != null) { XMLUtils.addSaxString(contentHandler, "USERNAME", username); } if (groupname != null) { XMLUtils.addSaxString(contentHandler, "GROUPNAME", groupname); } }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "SRC", src); XMLUtils.addSaxString(contentHandler, "NSQUOTA", Long.toString(nsQuota)); XMLUtils.addSaxString(contentHandler, "DSQUOTA", Long.toString(dsQuota)); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "SRC", src); XMLUtils.addSaxString(contentHandler, "STORAGETYPE", Integer.toString(type.ordinal())); XMLUtils.addSaxString(contentHandler, "DSQUOTA", Long.toString(dsQuota)); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "PATH", path); XMLUtils.addSaxString(contentHandler, "MTIME", Long.toString(mtime)); XMLUtils.addSaxString(contentHandler, "ATIME", Long.toString(atime)); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "LENGTH", Integer.toString(length)); XMLUtils.addSaxString(contentHandler, "INODEID", Long.toString(inodeId)); XMLUtils.addSaxString(contentHandler, "PATH", path); XMLUtils.addSaxString(contentHandler, "VALUE", value); XMLUtils.addSaxString(contentHandler, "MTIME", Long.toString(mtime)); XMLUtils.addSaxString(contentHandler, "ATIME", Long.toString(atime)); FSEditLogOp.permissionStatusToXml(contentHandler, permissionStatus); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "SRC", src); XMLUtils.addSaxString(contentHandler, "CLIENTNAME", clientName); XMLUtils.addSaxString(contentHandler, "CLIENTMACHINE", clientMachine); XMLUtils.addSaxString(contentHandler, "NEWLENGTH", Long.toString(newLength)); XMLUtils.addSaxString(contentHandler, "TIMESTAMP", Long.toString(timestamp)); if(truncateBlock != null) FSEditLogOp.blockToXml(contentHandler, truncateBlock); }
@Override protected void toXml(ContentHandler contentHandler) throws SAXException { XMLUtils.addSaxString(contentHandler, "SNAPSHOTROOT", snapshotRoot); XMLUtils.addSaxString(contentHandler, "SNAPSHOTOLDNAME", snapshotOldName); XMLUtils.addSaxString(contentHandler, "SNAPSHOTNEWNAME", snapshotNewName); appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId); }
public void outputToXml(ContentHandler contentHandler) throws SAXException { contentHandler.startElement("", "", "RECORD", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "OPCODE", opCode.toString()); contentHandler.startElement("", "", "DATA", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "TXID", "" + txid); toXml(contentHandler); contentHandler.endElement("", "", "DATA"); contentHandler.endElement("", "", "RECORD"); }
public static void blockToXml(ContentHandler contentHandler, Block block) throws SAXException { contentHandler.startElement("", "", "BLOCK", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "BLOCK_ID", Long.toString(block.getBlockId())); XMLUtils.addSaxString(contentHandler, "NUM_BYTES", Long.toString(block.getNumBytes())); XMLUtils.addSaxString(contentHandler, "GENSTAMP", Long.toString(block.getGenerationStamp())); contentHandler.endElement("", "", "BLOCK"); }
public static void delegationKeyToXml(ContentHandler contentHandler, DelegationKey key) throws SAXException { contentHandler.startElement("", "", "DELEGATION_KEY", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "KEY_ID", Integer.toString(key.getKeyId())); XMLUtils.addSaxString(contentHandler, "EXPIRY_DATE", Long.toString(key.getExpiryDate())); if (key.getEncodedKey() != null) { XMLUtils.addSaxString(contentHandler, "KEY", Hex.encodeHexString(key.getEncodedKey())); } contentHandler.endElement("", "", "DELEGATION_KEY"); }
public static void permissionStatusToXml(ContentHandler contentHandler, PermissionStatus perm) throws SAXException { contentHandler.startElement("", "", "PERMISSION_STATUS", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "USERNAME", perm.getUserName()); XMLUtils.addSaxString(contentHandler, "GROUPNAME", perm.getGroupName()); fsPermissionToXml(contentHandler, perm.getPermission()); contentHandler.endElement("", "", "PERMISSION_STATUS"); }
private static void appendAclEntriesToXml(ContentHandler contentHandler, List<AclEntry> aclEntries) throws SAXException { for (AclEntry e : aclEntries) { contentHandler.startElement("", "", "ENTRY", new AttributesImpl()); XMLUtils.addSaxString(contentHandler, "SCOPE", e.getScope().name()); XMLUtils.addSaxString(contentHandler, "TYPE", e.getType().name()); if (e.getName() != null) { XMLUtils.addSaxString(contentHandler, "NAME", e.getName()); } fsActionToXml(contentHandler, e.getPermission()); contentHandler.endElement("", "", "ENTRY"); } }