Package com.mapr.baseutils.utils
Class Util
java.lang.Object
com.mapr.baseutils.utils.Util
Utility class
Mostly static functions
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanAddToTruststore(String certificate, String cluster, String truststorePath, boolean alreadyExist) static booleanAddToTruststore(Map<String, String> clusterCert, String truststorePath, boolean alreadyExist) static StringaeKeyToString(com.mapr.fs.cldb.proto.CLDBProto.AeKey key) static intbyteArraytoInt(byte[] byteArray) static com.mapr.fs.proto.Common.IPAddressbyteArrToIPAddress(byte[] byteIpArr) static com.mapr.fs.proto.Security.IpAddrMsgbyteArrToIpAddrMsg(byte[] byteIpArr) static StringbyteArrToSocketAddrStr(byte[] byteArr, int port) static booleancompareFidMsg(com.mapr.fs.proto.Common.FidMsg a, com.mapr.fs.proto.Common.FidMsg b) static booleancompareIPAddress(com.mapr.fs.proto.Common.IPAddress a, com.mapr.fs.proto.Common.IPAddress b) static booleancompareIpFromServer(com.mapr.fs.proto.Common.Server server1, com.mapr.fs.proto.Common.Server server2, int index) static booleancompareServers(com.mapr.fs.proto.Common.Server a, long b) static booleancompareServers(com.mapr.fs.proto.Common.Server a, com.mapr.fs.proto.Common.Server b) static longcurrentMillisFromMapRTime(int seconds) static voiddelete_ssocert_in_truststore(KeyStore truststore, String alias) static longelapsedTimeGreaterThan(long lastLoggedTime, long skipMillis) static Stringstatic booleanexistInTruststore(String cluster, String truststorePath) static StringexpandSpId(String spid) static longgetCeil(long val, long interval) getChangedAlarmGroupEntries(com.mapr.fs.proto.Common.AlarmGroupConfigMsg oldConfig, com.mapr.fs.proto.Common.AlarmGroupConfigMsg newConfig) getChangedOffloadRuleProps(com.mapr.fs.cldb.proto.CLDBProto.OffloadRuleProperties oldProps, com.mapr.fs.cldb.proto.CLDBProto.OffloadRuleProperties newProps) getChangedTierProps(com.mapr.fs.cldb.proto.CLDBProto.TierProperties oldProps, com.mapr.fs.cldb.proto.CLDBProto.TierProperties newProps) static intgetContainerActualSize(int ownedSizeMB, int sharedSizeMB, int chainSizeMB) static intgetContainerActualSize(com.mapr.fs.cldb.proto.CLDBProto.ContainerSizeInfo c) static Stringstatic longgetFloor(long val, long interval) static intgetHigherIntFromLong(long number) Return all local IPAddress.static StringgetHostname(com.mapr.fs.proto.Common.Server server, int index) static com.mapr.fs.proto.Common.IPAddressgetIPAddress(com.mapr.fs.proto.Common.Server server, boolean isExternal) static List<com.mapr.fs.proto.Common.IPAddress>getIPAddressList(com.mapr.fs.cldb.proto.CLDBProto.FileServerRegisterRequest freq) static List<com.mapr.fs.proto.Common.IPAddress>getIPAddressList(com.mapr.fs.proto.Common.Server server, boolean isExternal) static List<CLDBRpcCommonUtils.IpAddr>getIpAddrListFromIp(List<Integer> ipv4AddressList, List<com.mapr.fs.proto.Security.IpAddrMsg> ipv6AdressList) static StringgetLogMsgIfMalformed(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo cInfo) static intgetLowerIntFromLong(long number) static intgetMapRTimeInSeconds(long millis) static longgetMax(int number) static longgetMin(int number) static StringgetNameFromVolumenoteKey(String noteKey) static com.mapr.fs.proto.Common.NodePropertiesstatic CLDBRpcCommonUtils.IpAddrgetOneIPAddress(List<com.mapr.fs.proto.Common.IPAddress> ips, boolean isIPv6) static StringgetParentInTopology(String topo) static IntegergetPort(com.mapr.fs.proto.Common.Server server, int index) static byte[]static List<CLDBRpcCommonUtils.SocketAddr>getSocketAddrListFromIPPort(com.mapr.fs.proto.Common.IPPort ipPort) static com.mapr.fs.proto.Common.GuidMsggetUniqueVolumeUuid(com.mapr.fs.proto.Common.GuidMsg clusterUuid, com.mapr.fs.cldb.proto.CLDBProto.VolumeProperties volProps) static intgetVolIdFromVolumenoteKey(String noteKey) static StringgetVolumeEnforcementModeName(boolean enforcePolicies, boolean enforceAces, boolean auditOnlyPolicyCheck) static StringgetVolumenoteKey(int volId, String noteName) static booleanhasDeviceOverlap(List<com.mapr.fs.proto.Common.InterfaceInfo> list1, List<com.mapr.fs.proto.Common.InterfaceInfo> list2) static booleanhasOverlap(List<?> list1, List<?> list2) static longhexToLong(byte[] bytes) Converts a string of ascii hexadecimal characters into a Long integer.static byte[]intToByteArray(int val) static StringintToIp(int i) static byte[]ipAddrMsgToByteArray(com.mapr.fs.proto.Security.IpAddrMsg ipAddrMsg) static booleanipBelongsToServer(com.mapr.fs.proto.Common.Server server, com.mapr.fs.proto.Common.IPAddress toCompare) static intstatic longstatic Stringipv4ByteArrToStr(byte[] byteArr) static Stringipv6ByteArrToStr(byte[] byteArr) static voidisDuplicateIPinContainer(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo cInfo) static booleanisDuplicateIPinServer(com.mapr.fs.proto.Common.Server s) static booleanstatic booleanstatic booleanisNullOrEmpty(String str) static booleanisValidIpAddress(byte[] byteArr) static booleanisValidPort(int port) static StringlimitDecimalTo2(double d) static StringlongToIp(long i) static longmakeLongFromInts(long higher, long lower) static booleanmoveTrustStore(String srcTrustStorePath, String dstTrustStorePath) parseSocket(String socketAddress) static StringpringGuid(com.mapr.fs.proto.Common.GuidMsg guid) static StringprintableKey(byte[] bytes) static StringprintContainerInfoForCLI(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo c) static StringprintContainerInfoWithServerId(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo c) static StringprintContainerInfoWithServerId(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo c, boolean verbose) static StringprintContainerSizeInfo(com.mapr.fs.cldb.proto.CLDBProto.ContainerSizeInfo c) static StringprintCredentials(com.mapr.fs.proto.Security.CredentialsMsg creds) static StringprintExternalIPAddressesForCLI(List<com.mapr.fs.proto.Common.IPAddress> ips, List<Integer> ports) static StringPrintExtIpAddressesForCli(com.mapr.fs.proto.Common.Server server) static StringprintFidMsg(com.mapr.fs.proto.Common.FidMsg a) static StringprintInitialContainerInfo(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo c) static StringprintIPAddress(int host, int port) static StringprintIPAddress(com.mapr.fs.proto.Common.IPAddress ip) static StringprintIPAddresses(com.mapr.fs.proto.Common.Server server) static StringprintIPAddresses(List<com.mapr.fs.proto.Common.IPAddress> ips) static StringprintIPAddressesForCLI(com.mapr.fs.proto.Common.Server server) static StringprintIPAddressesForCLI(List<com.mapr.fs.proto.Common.IPAddress> ips) static StringprintIPAddressesWithHostname(List<com.mapr.fs.proto.Common.IPAddress> ips) static StringprintIPAddressForCLI(com.mapr.fs.proto.Common.IPAddress ip) static StringprintIpAddrListAndPortListInfo(List<CLDBRpcCommonUtils.IpAddr> ipAddrList, List<Integer> ports) static StringprintOneIpAddress(com.mapr.fs.proto.Common.Server server) static StringprintOneIpAddress(List<com.mapr.fs.proto.Common.IPAddress> ips) static StringprintPorts(List<Integer> ports) static StringprintRdmaPort(com.mapr.fs.proto.Common.Server s, int firstPort) static StringprintServer(com.mapr.fs.proto.Common.Server server) static StringprintServerList(List<com.mapr.fs.proto.Common.Server> servers) static StringprintServerWithNoState(com.mapr.fs.proto.Common.Server s) static StringprintServerWithNoStateForCLI(com.mapr.fs.proto.Common.Server s) static StringprintServerWithNoStateForCLI(com.mapr.fs.proto.Common.Server s, boolean getCtime) static StringprintServerWithState(com.mapr.fs.proto.Common.Server s) static StringprintServerWithStateForCLI(com.mapr.fs.proto.Common.Server s) static StringprintServerWithStateForCLI(com.mapr.fs.proto.Common.Server s, boolean getCtime) static StringprintSimpleDateFormat(com.mapr.fs.proto.Common.FileTimeMsg time) static StringprintSPIds(List<com.mapr.fs.proto.Common.StoragePoolInfo> sps) static StringprintVolumeAccessControl(int volId, com.mapr.fs.proto.Common.VolumeAces va) static StringreadableSizeMB(long sizeMB) static longreadableSizeToSizeMB(String size) static voidremoveFromTruststore(String cluster, String truststorePath) static StringreplicaStateToString(com.mapr.fs.proto.Common.Server.ReplicaState replState) static longroundTimeStampToMidnight(long timeOfDay) Computes millis since epoch at midnight for the day represented by timeOfDay.static com.mapr.fs.proto.Common.IPAddressrpcCallContextToIPAddress(RpcCallContext context) static StringshrinkSpId(String spid) shrink and expand spid from hexadecimal to a stringstatic voidupdatesTruststore(String inCertificate, KeyStore truststore, String alias)
-
Field Details
-
SEC
public static int SEC -
MIN
public static int MIN -
FIVE_MIN
public static int FIVE_MIN -
PORT_MIN
public static int PORT_MIN -
PORT_MAX
public static int PORT_MAX -
IPV4_ADDR_SIZE
public static final int IPV4_ADDR_SIZE- See Also:
-
IPV6_ADDR_SIZE
public static final int IPV6_ADDR_SIZE- See Also:
-
nodePropertiesFile
-
PATH_SEPERATOR_STR
- See Also:
-
ROOT
- See Also:
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
intToIp
-
isValidPort
public static boolean isValidPort(int port) -
ipAddrMsgToByteArray
public static byte[] ipAddrMsgToByteArray(com.mapr.fs.proto.Security.IpAddrMsg ipAddrMsg) -
intToByteArray
public static byte[] intToByteArray(int val) -
isValidIpAddress
public static boolean isValidIpAddress(byte[] byteArr) -
ipv4ByteArrToStr
- Throws:
IllegalArgumentException
-
ipv6ByteArrToStr
- Throws:
IllegalArgumentException
-
byteArrToSocketAddrStr
-
byteArrToIpAddrMsg
public static com.mapr.fs.proto.Security.IpAddrMsg byteArrToIpAddrMsg(byte[] byteIpArr) -
rpcCallContextToIPAddress
-
byteArrToIPAddress
public static com.mapr.fs.proto.Common.IPAddress byteArrToIPAddress(byte[] byteIpArr) -
byteArraytoInt
public static int byteArraytoInt(byte[] byteArray) -
isNullOrEmpty
-
ipToInt
-
ipToLong
-
getSocketAddrListFromIPPort
public static List<CLDBRpcCommonUtils.SocketAddr> getSocketAddrListFromIPPort(com.mapr.fs.proto.Common.IPPort ipPort) -
longToIp
-
readableSizeMB
-
readableSizeToSizeMB
-
limitDecimalTo2
-
makeLongFromInts
public static long makeLongFromInts(long higher, long lower) -
getHigherIntFromLong
public static int getHigherIntFromLong(long number) -
getLowerIntFromLong
public static int getLowerIntFromLong(long number) -
getMin
public static long getMin(int number) -
getMax
public static long getMax(int number) -
ipBelongsToServer
public static boolean ipBelongsToServer(com.mapr.fs.proto.Common.Server server, com.mapr.fs.proto.Common.IPAddress toCompare) -
printSimpleDateFormat
-
printFidMsg
-
printIPAddress
-
printServerList
-
printServer
-
printIPAddress
-
exceptionToString
-
printIPAddresses
-
printOneIpAddress
-
printOneIpAddress
-
printIpAddrListAndPortListInfo
public static String printIpAddrListAndPortListInfo(List<CLDBRpcCommonUtils.IpAddr> ipAddrList, List<Integer> ports) -
getIpAddrListFromIp
public static List<CLDBRpcCommonUtils.IpAddr> getIpAddrListFromIp(List<Integer> ipv4AddressList, List<com.mapr.fs.proto.Security.IpAddrMsg> ipv6AdressList) -
printIPAddresses
-
printIPAddressesWithHostname
-
printPorts
-
printSPIds
-
printServerWithState
-
printServerWithNoState
-
printContainerInfoWithServerId
public static String printContainerInfoWithServerId(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo c) -
printContainerInfoWithServerId
public static String printContainerInfoWithServerId(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo c, boolean verbose) -
getLogMsgIfMalformed
-
printInitialContainerInfo
-
replicaStateToString
-
printContainerSizeInfo
-
compareIPAddress
public static boolean compareIPAddress(com.mapr.fs.proto.Common.IPAddress a, com.mapr.fs.proto.Common.IPAddress b) -
getIPAddressList
public static List<com.mapr.fs.proto.Common.IPAddress> getIPAddressList(com.mapr.fs.cldb.proto.CLDBProto.FileServerRegisterRequest freq) -
compareIpFromServer
public static boolean compareIpFromServer(com.mapr.fs.proto.Common.Server server1, com.mapr.fs.proto.Common.Server server2, int index) -
getPort
-
getIPAddressList
public static List<com.mapr.fs.proto.Common.IPAddress> getIPAddressList(com.mapr.fs.proto.Common.Server server, boolean isExternal) -
getIPAddress
public static com.mapr.fs.proto.Common.IPAddress getIPAddress(com.mapr.fs.proto.Common.Server server, boolean isExternal) -
getHostname
-
getOneIPAddress
public static CLDBRpcCommonUtils.IpAddr getOneIPAddress(List<com.mapr.fs.proto.Common.IPAddress> ips, boolean isIPv6) -
isDuplicateIPinServer
public static boolean isDuplicateIPinServer(com.mapr.fs.proto.Common.Server s) -
isDuplicateIPinContainer
public static void isDuplicateIPinContainer(com.mapr.fs.cldb.proto.CLDBProto.ContainerInfo cInfo) -
compareServers
public static boolean compareServers(com.mapr.fs.proto.Common.Server a, com.mapr.fs.proto.Common.Server b) -
compareServers
public static boolean compareServers(com.mapr.fs.proto.Common.Server a, long b) -
compareFidMsg
public static boolean compareFidMsg(com.mapr.fs.proto.Common.FidMsg a, com.mapr.fs.proto.Common.FidMsg b) -
getFloor
public static long getFloor(long val, long interval) -
getCeil
public static long getCeil(long val, long interval) -
aeKeyToString
-
getHostIPAddresses
Return all local IPAddress. Will filter out 127.0.0.1 and 127.0.1.1- Returns:
-
hexToLong
public static long hexToLong(byte[] bytes) Converts a string of ascii hexadecimal characters into a Long integer. The need for this function arises from the limitation of Long.parseLong function for signed long integers.- Parameters:
bytes- string of hexademical characters. Valid characters are '0-9', and 'a-z'.- Returns:
- long long values of the hexadecimal string.
-
isInteger
-
isNonNegativeInteger
-
roundTimeStampToMidnight
public static long roundTimeStampToMidnight(long timeOfDay) Computes millis since epoch at midnight for the day represented by timeOfDay. The date is interpreted in UTC timezone.- Returns:
- millis since epoch at midnight of the day in UTC
-
getContainerActualSize
public static int getContainerActualSize(com.mapr.fs.cldb.proto.CLDBProto.ContainerSizeInfo c) -
getContainerActualSize
public static int getContainerActualSize(int ownedSizeMB, int sharedSizeMB, int chainSizeMB) -
hasOverlap
-
hasDeviceOverlap
-
elapsedTimeGreaterThan
public static long elapsedTimeGreaterThan(long lastLoggedTime, long skipMillis) -
shrinkSpId
shrink and expand spid from hexadecimal to a string- Parameters:
spid-- Returns:
-
expandSpId
-
printIPAddressForCLI
-
printIPAddressesForCLI
-
parseSocket
-
PrintExtIpAddressesForCli
-
printIPAddressesForCLI
-
printExternalIPAddressesForCLI
-
printRdmaPort
-
printServerWithStateForCLI
- Throws:
Exception
-
printServerWithStateForCLI
public static String printServerWithStateForCLI(com.mapr.fs.proto.Common.Server s, boolean getCtime) throws Exception - Throws:
Exception
-
printServerWithNoStateForCLI
public static String printServerWithNoStateForCLI(com.mapr.fs.proto.Common.Server s) throws Exception - Throws:
Exception
-
printServerWithNoStateForCLI
public static String printServerWithNoStateForCLI(com.mapr.fs.proto.Common.Server s, boolean getCtime) throws Exception - Throws:
Exception
-
printContainerInfoForCLI
-
printCredentials
-
getUniqueVolumeUuid
public static com.mapr.fs.proto.Common.GuidMsg getUniqueVolumeUuid(com.mapr.fs.proto.Common.GuidMsg clusterUuid, com.mapr.fs.cldb.proto.CLDBProto.VolumeProperties volProps) -
pringGuid
-
getChangedAlarmGroupEntries
-
getChangedOffloadRuleProps
-
getChangedTierProps
-
getNameFromVolumenoteKey
-
getVolIdFromVolumenoteKey
-
getVolumenoteKey
-
getCurrentDate
-
getVolumeEnforcementModeName
public static String getVolumeEnforcementModeName(boolean enforcePolicies, boolean enforceAces, boolean auditOnlyPolicyCheck) -
printVolumeAccessControl
-
getMapRTimeInSeconds
public static int getMapRTimeInSeconds(long millis) -
currentMillisFromMapRTime
public static long currentMillisFromMapRTime(int seconds) -
getSHA256
-
printableKey
-
getNodeProperties
public static com.mapr.fs.proto.Common.NodeProperties getNodeProperties() -
getParentInTopology
-
updatesTruststore
public static void updatesTruststore(String inCertificate, KeyStore truststore, String alias) throws FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException -
delete_ssocert_in_truststore
public static void delete_ssocert_in_truststore(KeyStore truststore, String alias) throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException -
AddToTruststore
-
AddToTruststore
public static boolean AddToTruststore(String certificate, String cluster, String truststorePath, boolean alreadyExist) throws FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException -
moveTrustStore
public static boolean moveTrustStore(String srcTrustStorePath, String dstTrustStorePath) throws FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException -
removeFromTruststore
public static void removeFromTruststore(String cluster, String truststorePath) throws FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException -
existInTruststore
public static boolean existInTruststore(String cluster, String truststorePath) throws FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException
-