repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/NamespaceUpdater.java
smart-common/src/main/java/org/smartdata/model/NamespaceUpdater.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public interface NamespaceUpdater { void insertFile(FileInfo file); void insertFiles(FileInfo[] files); void updateFile(FileInfoMapper fileInfoMapper); void updateFiles(FileInfoMapper[] fileInfoMappers); void deleteFile(long fid); void deleteDirectory(String dirPath); void deleteAllFiles(); }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/DataNodeStorageInfo.java
smart-common/src/main/java/org/smartdata/model/DataNodeStorageInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class DataNodeStorageInfo { private String uuid; private long sid; private long state; private String storageId; private long failed; private long capacity; private long dfsUsed; private long remaining; private long blockPoolUsed; public DataNodeStorageInfo(String uuid, long sid, long state, String storageId, long failed, long capacity, long dfsUsed, long remaining, long blockPoolUsed) { this.uuid = uuid; this.sid = sid; this.state = state; this.storageId = storageId; this.failed = failed; this.capacity = capacity; this.dfsUsed = dfsUsed; this.remaining = remaining; this.blockPoolUsed = blockPoolUsed; } public DataNodeStorageInfo(String uuid, String storageType, long state, String storageId, long failed, long capacity, long dfsUsed, long remaining, long blockPoolUsed) { this.uuid = uuid; if (storageType.equals("ram")){ this.sid = 0; } if (storageType.equals("ssd")){ this.sid = 1; } if (storageType.equals("disk")){ this.sid = 2; } if (storageType.equals("archive")) { this.sid = 3; } this.state = state; this.storageId = storageId; this.failed = failed; this.capacity = capacity; this.dfsUsed = dfsUsed; this.remaining = remaining; this.blockPoolUsed = blockPoolUsed; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DataNodeStorageInfo that = (DataNodeStorageInfo) o; return sid == that.sid && state == that.state && failed == that.failed && capacity == that.capacity && dfsUsed == that.dfsUsed && remaining == that.remaining && blockPoolUsed == that.blockPoolUsed && Objects.equals(uuid, that.uuid) && Objects.equals(storageId, that.storageId); } @Override public int hashCode() { return Objects.hash( uuid, sid, state, storageId, failed, capacity, dfsUsed, remaining, blockPoolUsed); } public String getUuid() { return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } public long getSid() { return sid; } public void setSid(long sid) { this.sid = sid; } public void setSid(String storageType) { if (storageType.equals("ram")){ this.sid = 0; } if (storageType.equals("ssd")){ this.sid = 1; } if (storageType.equals("disk")){ this.sid = 2; } if (storageType.equals("archive")) { this.sid = 3; } } public long getState() { return state; } public void setState(long state) { this.state = state; } public String getStorageId() { return storageId; } public void setStorageId(String storageId) { this.storageId = storageId; } public long getFailed() { return failed; } public void setFailed(long failed) { this.failed = failed; } public long getCapacity() { return capacity; } public void setCapacity(long capacity) { this.capacity = capacity; } public long getDfsUsed() { return dfsUsed; } public void setDfsUsed(long dfsUsed) { this.dfsUsed = dfsUsed; } public long getRemaining() { return remaining; } public void setRemaining(long remaining) { this.remaining = remaining; } public long getBlockPoolUsed() { return blockPoolUsed; } public void setBlockPoolUsed(long blockPool) { this.blockPoolUsed = blockPool; } @Override public String toString() { return String.format( "DataNodeStorageInfo{uuid=\'%s\', sid=\'%s\', " + "state=%d, storage_id=\'%s\', failed=%d, capacity=%d, " + "dfs_used=%d, remaining=%d, block_pool_used=%d}", uuid, sid, state, storageId, failed, capacity, dfsUsed, remaining, blockPoolUsed); } public static Builder newBuilder() { return new Builder(); } public static class Builder { private String uuid; private long sid; private long state; private String storageId; private long failed; private long capacity; private long dfsUsed; private long remaining; private long blockPoolUsed; public Builder setUuid(String uuid) { this.uuid = uuid; return this; } public Builder setSid(long sid) { this.sid = sid; return this; } public Builder setState(long state) { this.state = state; return this; } public Builder setStorageId(String storageId) { this.storageId = storageId; return this; } public Builder setFailed(long failed) { this.failed = failed; return this; } public Builder setCapacity(long capacity) { this.capacity = capacity; return this; } public Builder setDfsUsed(long dfsUsed) { this.dfsUsed = dfsUsed; return this; } public Builder setRemaining(long remaining) { this.remaining = remaining; return this; } public Builder setBlockPoolUsed(long blockPoolUsed) { this.blockPoolUsed = blockPoolUsed; return this; } public DataNodeStorageInfo build() { return new DataNodeStorageInfo(uuid, sid, state, storageId, failed, capacity, dfsUsed, remaining, blockPoolUsed); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/XAttribute.java
smart-common/src/main/java/org/smartdata/model/XAttribute.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Arrays; import java.util.Objects; public class XAttribute { private final String nameSpace; private final String name; private final byte[] value; public XAttribute(String nameSpace, String name, byte[] value) { this.nameSpace = nameSpace; this.name = name; this.value = value; } public String getNameSpace() { return nameSpace; } public String getName() { return name; } public byte[] getValue() { return value; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } XAttribute that = (XAttribute) o; return Objects.equals(nameSpace, that.nameSpace) && Objects.equals(name, that.name) && Arrays.equals(value, that.value); } @Override public int hashCode() { return Objects.hash(nameSpace, name, value); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CompressionTrunk.java
smart-common/src/main/java/org/smartdata/model/CompressionTrunk.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * CompressionTrunk is the unit of file compression. */ public class CompressionTrunk { private int index; private String compressionImpl; private long originOffset; private long originLength; private long compressedOffset; private long compressedLength; public CompressionTrunk(int index) { this(index, "snappy", 0, 0, 0, 0); } public CompressionTrunk(int index, String compressionImpl, long originOffset, long originLength, long compressedOffset, long compressedLength) { this.index = index; this.compressionImpl = compressionImpl; this.originOffset = originOffset; this.originLength = originLength; this.compressedOffset = compressedOffset; this.compressedLength = compressedLength; } public String getCompressionImpl() { return compressionImpl; } public void setOriginOffset(long originOffset) { this.originOffset = originOffset; } public void setOriginLength(long originLength) { this.originLength = originLength; } public void setCompressedOffset(long compressedOffset) { this.compressedOffset = compressedOffset; } public void setCompressedLength(long compressedLength) { this.compressedLength = compressedLength; } public int getIndex() { return index; } public void setCompressionImpl(String compressionImpl) { this.compressionImpl = compressionImpl; } public long getOriginOffset() { return originOffset; } public long getOriginLength() { return originLength; } public long getCompressedOffset() { return compressedOffset; } public long getCompressedLength() { return compressedLength; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CompressionType.java
smart-common/src/main/java/org/smartdata/model/CompressionType.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * Compression/Codec enum. */ public enum CompressionType { /** * uncompressed/raw data. */ raw(0), /** * snappy. */ snappy(1), /** * Lz4. */ Lz4(2), /** * Bzip2, splitable. */ Bzip2(3), /** * Zlib. */ Zlib(4); private final int value; CompressionType(int value) { this.value = value; } public int getValue() { return value; } /** * Return CompressionType from a given value (int). * @param value (int) * @return CompressionType of this value */ public static CompressionType fromValue(int value) { for (CompressionType t : values()) { if (t.getValue() == value) { return t; } } return null; } /** * Return CompressionType from a given String. * @param name String of a codec * @return CompressionType of this String */ public static CompressionType fromName(String name) { for (CompressionType t : values()) { if (t.toString().equalsIgnoreCase(name)) { return t; } } return null; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ActionType.java
smart-common/src/main/java/org/smartdata/model/ActionType.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * Internal actions supported. */ public enum ActionType { None(0), // doing nothing External(1), // execute some cmdlet lines specified CacheFile(2), // Move to cache UncacheFile(3), // Move out of cache SetStoragePolicy(4), // Set Policy Action MoveFile(5), // Enforce storage Policy ArchiveFile(6), // Enforce Archive Policy ConvertToEC(7), ConvertToReplica(8), Distcp(9), DiskBalance(10), BalanceCluster(11); private final int value; ActionType(int value) { this.value = value; } public int getValue() { return value; } public static ActionType fromValue(int value) { for (ActionType t : values()) { if (t.getValue() == value) { return t; } } return null; } public static ActionType fromName(String name) { for (ActionType t : values()) { if (t.toString().equalsIgnoreCase(name)) { return t; } } return null; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileInfo.java
smart-common/src/main/java/org/smartdata/model/FileInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class FileInfo { private String path; private long fileId; private long length; private boolean isdir; private short blockReplication; private long blocksize; private long modificationTime; private long accessTime; private short permission; private String owner; private String group; private byte storagePolicy; private byte erasureCodingPolicy; public FileInfo(String path, long fileId, long length, boolean isdir, short blockReplication, long blocksize, long modificationTime, long accessTime, short permission, String owner, String group, byte storagePolicy, byte erasureCodingPolicy) { this.path = path; this.fileId = fileId; this.length = length; this.isdir = isdir; this.blockReplication = blockReplication; this.blocksize = blocksize; this.modificationTime = modificationTime; this.accessTime = accessTime; this.permission = permission; this.owner = owner; this.group = group; this.storagePolicy = storagePolicy; this.erasureCodingPolicy = erasureCodingPolicy; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public long getFileId() { return fileId; } public void setFileId(long fileId) { this.fileId = fileId; } public long getLength() { return length; } public void setLength(long length) { this.length = length; } public boolean isdir() { return isdir; } public void setIsdir(boolean isdir) { this.isdir = isdir; } public short getBlockReplication() { return blockReplication; } public void setBlockReplication(short blockReplication) { this.blockReplication = blockReplication; } public long getBlocksize() { return blocksize; } public void setBlocksize(long blocksize) { this.blocksize = blocksize; } public long getModificationTime() { return modificationTime; } public void setModificationTime(long modificationTime) { this.modificationTime = modificationTime; } public long getAccessTime() { return accessTime; } public void setAccessTime(long accessTime) { this.accessTime = accessTime; } public short getPermission() { return permission; } public void setPermission(short permission) { this.permission = permission; } public String getOwner() { return owner; } public void setOwner(String owner) { this.owner = owner; } public String getGroup() { return group; } public void setGroup(String group) { this.group = group; } public byte getStoragePolicy() { return storagePolicy; } public void setStoragePolicy(byte storagePolicy) { this.storagePolicy = storagePolicy; } public byte getErasureCodingPolicy() { return erasureCodingPolicy; } public void setErasureCodingPolicy(byte erasureCodingPolicy) { this.erasureCodingPolicy = erasureCodingPolicy; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FileInfo fileInfo = (FileInfo) o; return fileId == fileInfo.fileId && length == fileInfo.length && isdir == fileInfo.isdir && blockReplication == fileInfo.blockReplication && blocksize == fileInfo.blocksize && modificationTime == fileInfo.modificationTime && accessTime == fileInfo.accessTime && permission == fileInfo.permission && storagePolicy == fileInfo.storagePolicy && erasureCodingPolicy == fileInfo.erasureCodingPolicy && Objects.equals(path, fileInfo.path) && Objects.equals(owner, fileInfo.owner) && Objects.equals(group, fileInfo.group); } @Override public int hashCode() { return Objects.hash( path, fileId, length, isdir, blockReplication, blocksize, modificationTime, accessTime, permission, owner, group, storagePolicy, erasureCodingPolicy); } public static Builder newBuilder() { return new Builder(); } @Override public String toString() { return String.format( "FileInfo{path=\'%s\', fileId=%s, length=%s, isdir=%s, blockReplication=%s, " + "blocksize=%s, modificationTime=%s, accessTime=%s, permission=%s, owner=\'%s\', " + "group=\'%s\', storagePolicy=%s, erasureCodingPolicy=%s}", path, fileId, length, isdir, blockReplication, blocksize, modificationTime, accessTime, permission, owner, group, storagePolicy, erasureCodingPolicy); } public static class Builder { private String path; private long fileId; private long length; private boolean isdir; private short blockReplication; private long blocksize; private long modificationTime; private long accessTime; private short permission; private String owner; private String group; private byte storagePolicy; private byte erasureCodingPolicy; public Builder setPath(String path) { this.path = path; return this; } public Builder setFileId(long fileId) { this.fileId = fileId; return this; } public Builder setLength(long length) { this.length = length; return this; } public Builder setIsdir(boolean isdir) { this.isdir = isdir; return this; } public Builder setBlockReplication(short blockReplication) { this.blockReplication = blockReplication; return this; } public Builder setBlocksize(long blocksize) { this.blocksize = blocksize; return this; } public Builder setModificationTime(long modificationTime) { this.modificationTime = modificationTime; return this; } public Builder setAccessTime(long accessTime) { this.accessTime = accessTime; return this; } public Builder setPermission(short permission) { this.permission = permission; return this; } public Builder setOwner(String owner) { this.owner = owner; return this; } public Builder setGroup(String group) { this.group = group; return this; } public Builder setStoragePolicy(byte storagePolicy) { this.storagePolicy = storagePolicy; return this; } public Builder setErasureCodingPolicy(byte erasureCodingPolicy) { this.erasureCodingPolicy = erasureCodingPolicy; return this; } public FileInfo build() { return new FileInfo(path, fileId, length, isdir, blockReplication, blocksize, modificationTime, accessTime, permission, owner, group, storagePolicy, erasureCodingPolicy); } @Override public String toString() { return String.format( "Builder{path=\'%s\', fileId=%s, length=%s, isdir=%s, blockReplication=%s, " + "blocksize=%s, modificationTime=%s, accessTime=%s, permission=%s, owner=\'%s\', " + "group=\'%s\', storagePolicy=%s, erasureCodingPolicy=%s}", path, fileId, length, isdir, blockReplication, blocksize, modificationTime, accessTime, permission, owner, group, storagePolicy, erasureCodingPolicy); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CompressionFileInfo.java
smart-common/src/main/java/org/smartdata/model/CompressionFileInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * This class is used between compression scheduler and action. It maintains CompressionFileState * generated by CompressionAction and the temp file path for CompressionAction to store the * compressed file. After CompressionScheduler gets this class, it will replace the original file * with the temp compressed file and then update the metastore with CompressionFileState. */ public class CompressionFileInfo { private boolean needReplace = false; private String tempPath = null; private CompressionFileState compressionFileState = null; public CompressionFileInfo(boolean needReplace, CompressionFileState compressionFileState) { this(needReplace, null, compressionFileState); } public CompressionFileInfo(CompressionFileState compressionFileState) { this(false, null, compressionFileState); } public CompressionFileInfo(boolean needReplace, String tempPath, CompressionFileState compressionFileState) { this.needReplace = needReplace; this.tempPath = tempPath; this.compressionFileState = compressionFileState; } public void setCompressionFileState(CompressionFileState compressionFileState) { this.compressionFileState = compressionFileState; } public void setTempPath(String tempPath) { this.tempPath = tempPath; } public void setNeedReplace(boolean needReplace) { this.needReplace = needReplace; } public CompressionFileState getCompressionFileState() { return compressionFileState; } public String getTempPath() { return tempPath; } public boolean needReplace() { return needReplace; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ClusterType.java
smart-common/src/main/java/org/smartdata/model/ClusterType.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public enum ClusterType { HDFS, ALLUXIO }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/RuleInfo.java
smart-common/src/main/java/org/smartdata/model/RuleInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Objects; /** * Contains info about a rule inside SSM. */ public class RuleInfo implements Cloneable { private long id; private long submitTime; private String ruleText; private RuleState state; // Some static information about rule private long numChecked; private long numCmdsGen; private long lastCheckTime; public long getId() { return id; } public void setId(long id) { this.id = id; } public long getSubmitTime() { return submitTime; } public void setSubmitTime(long submitTime) { this.submitTime = submitTime; } public String getRuleText() { return ruleText; } public void setRuleText(String ruleText) { this.ruleText = ruleText; } public RuleState getState() { return state; } public void setState(RuleState state) { this.state = state; } public long getNumChecked() { return numChecked; } public void setNumChecked(long numChecked) { this.numChecked = numChecked; } public long getNumCmdsGen() { return numCmdsGen; } public void setNumCmdsGen(long numCmdsGen) { this.numCmdsGen = numCmdsGen; } public long getLastCheckTime() { return lastCheckTime; } public void setLastCheckTime(long lastCheckTime) { this.lastCheckTime = lastCheckTime; } public void updateRuleInfo(RuleState rs, long lastCheckTime, long checkedCount, int cmdletsGen) { if (rs != null) { this.state = rs; } if (lastCheckTime != 0) { this.lastCheckTime = lastCheckTime; } this.numChecked += checkedCount; this.numCmdsGen += cmdletsGen; } public RuleInfo() { } public RuleInfo(long id, long submitTime, String ruleText, RuleState state, long numChecked, long numCmdsGen, long lastCheckTime) { this.id = id; this.submitTime = submitTime; this.ruleText = ruleText; this.state = state; this.numChecked = numChecked; this.numCmdsGen = numCmdsGen; this.lastCheckTime = lastCheckTime; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RuleInfo ruleInfo = (RuleInfo) o; return id == ruleInfo.id && submitTime == ruleInfo.submitTime && numChecked == ruleInfo.numChecked && numCmdsGen == ruleInfo.numCmdsGen && lastCheckTime == ruleInfo.lastCheckTime && Objects.equals(ruleText, ruleInfo.ruleText) && state == ruleInfo.state; } @Override public int hashCode() { return Objects.hash(id, submitTime, ruleText, state, numChecked, numCmdsGen, lastCheckTime); } @Override public String toString() { StringBuffer sb = new StringBuffer(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date submitDate = new Date(submitTime); String lastCheck = "Not Checked"; if (lastCheckTime != 0) { Date lastCheckDate = new Date(lastCheckTime); lastCheck = sdf.format(lastCheckDate); } sb.append("{ id = ") .append(id) .append(", submitTime = '") .append(sdf.format(submitDate)) .append("'") .append(", State = ") .append(state.toString()) .append(", lastCheckTime = '") .append(lastCheck) .append("'") .append(", numChecked = ") .append(numChecked) .append(", numCmdsGen = ") .append(numCmdsGen) .append(" }"); return sb.toString(); } public RuleInfo newCopy() { return new RuleInfo(id, submitTime, ruleText, state, numChecked, numCmdsGen, lastCheckTime); } public static Builder newBuilder() { return Builder.create(); } public static class Builder { private long id; private long submitTime; private String ruleText; private RuleState state; private long numChecked; private long numCmdsGen; private long lastCheckTime; public static Builder create() { return new Builder(); } public Builder setId(long id) { this.id = id; return this; } public Builder setSubmitTime(long submitTime) { this.submitTime = submitTime; return this; } public Builder setRuleText(String ruleText) { this.ruleText = ruleText; return this; } public Builder setState(RuleState state) { this.state = state; return this; } public Builder setNumChecked(long numChecked) { this.numChecked = numChecked; return this; } public Builder setNumCmdsGen(long numCmdsGen) { this.numCmdsGen = numCmdsGen; return this; } public Builder setLastCheckTime(long lastCheckTime) { this.lastCheckTime = lastCheckTime; return this; } public RuleInfo build() { return new RuleInfo(id, submitTime, ruleText, state, numChecked, numCmdsGen, lastCheckTime); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ClusterInfo.java
smart-common/src/main/java/org/smartdata/model/ClusterInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class ClusterInfo { private long cid; private String name; private String url; private String confPath; private String state; private String type; public ClusterInfo( long cid, String name, String url, String confPath, String state, String type) { this.cid = cid; this.name = name; this.url = url; this.confPath = confPath; this.state = state; this.type = type; } public ClusterInfo() { } public long getCid() { return cid; } public void setCid(long cid) { this.cid = cid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getConfPath() { return confPath; } public void setConfPath(String confPath) { this.confPath = confPath; } public String getState() { return state; } public void setState(String state) { this.state = state; } public String getType() { return type; } public void setType(String type) { this.type = type; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ClusterInfo that = (ClusterInfo) o; return cid == that.cid && Objects.equals(name, that.name) && Objects.equals(url, that.url) && Objects.equals(confPath, that.confPath) && Objects.equals(state, that.state) && Objects.equals(type, that.type); } @Override public int hashCode() { return Objects.hash(cid, name, url, confPath, state, type); } @Override public String toString() { return String.format( "ClusterInfo{cid=%s, name=\'%s\', url=\'%s\', confPath=\'%s\', state=\'%s\', type=\'%s\'}", cid, name, url, confPath, state, type); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/SystemInfo.java
smart-common/src/main/java/org/smartdata/model/SystemInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class SystemInfo { private final String property; private final String value; public SystemInfo(String property, String value) { this.property = property; this.value = value; } public String getProperty() { return property; } public String getValue() { return value; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SystemInfo that = (SystemInfo) o; return Objects.equals(property, that.property) && Objects.equals(value, that.value); } @Override public int hashCode() { return Objects.hash(property, value); } @Override public String toString() { return String.format("SystemInfo{property=\'%s\', value=\'%s\'}", property, value); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileAccessInfo.java
smart-common/src/main/java/org/smartdata/model/FileAccessInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class FileAccessInfo { private Long fid; private String path; private Integer accessCount; public FileAccessInfo(Long fid, String path, Integer accessCount) { this.fid = fid; this.path = path; this.accessCount = accessCount; } public Long getFid() { return fid; } public void setFid(Long fid) { this.fid = fid; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public Integer getAccessCount() { return accessCount; } public void setAccessCount(Integer accessCount) { this.accessCount = accessCount; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FileAccessInfo that = (FileAccessInfo) o; return Objects.equals(fid, that.fid) && Objects.equals(path, that.path) && Objects.equals(accessCount, that.accessCount); } @Override public int hashCode() { return Objects.hash(fid, path, accessCount); } @Override public String toString() { return String.format( "FileAccessInfo{fid=%s, path=\'%s\', accessCount=%s}", fid, path, accessCount); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileState.java
smart-common/src/main/java/org/smartdata/model/FileState.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.io.Serializable; import java.util.Objects; /** * FileState. */ public class FileState implements Serializable { protected String path; protected FileType fileType; protected FileStage fileStage; public FileState(String path, FileType fileType, FileStage fileStage) { this.path = path; this.fileType = fileType; this.fileStage = fileStage; } public String getPath() { return path; } public FileType getFileType() { return fileType; } public FileStage getFileStage() { return fileStage; } public void setFileStage(FileStage fileStage) { this.fileStage = fileStage; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FileState fileState = (FileState) o; return path.equals(fileState.getPath()) && fileType.equals(fileState.getFileType()) && fileStage.equals(fileState.getFileStage()); } @Override public int hashCode() { return Objects.hash(path, fileType, fileStage); } /** * FileType indicates type of a file. */ public enum FileType { NORMAL(0), COMPACT(1), COMPRESSION(2), S3(3); private final int value; FileType(int value) { this.value = value; } public int getValue() { return value; } public static FileType fromValue(int value) { for (FileType t : values()) { if (t.getValue() == value) { return t; } } return null; } public static FileType fromName(String name) { for (FileType t : values()) { if (t.toString().equalsIgnoreCase(name)) { return t; } } return null; } } public enum FileStage { PROCESSING(0), DONE(1); private final int value; FileStage(int value) { this.value = value; } public int getValue() { return value; } public static FileStage fromValue(int value) { for (FileStage t : values()) { if (t.getValue() == value) { return t; } } return null; } public static FileStage fromName(String name) { for (FileStage t : values()) { if (t.toString().equalsIgnoreCase(name)) { return t; } } return null; } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ClusterState.java
smart-common/src/main/java/org/smartdata/model/ClusterState.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public enum ClusterState { ENABLED, DISABLED }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/DetailedFileAction.java
smart-common/src/main/java/org/smartdata/model/DetailedFileAction.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public class DetailedFileAction extends ActionInfo { private String filePath; private long fileLength; private String src; private String target; public DetailedFileAction(ActionInfo actionInfo) { super(actionInfo.getActionId(), actionInfo.getCmdletId(), actionInfo.getActionName(), actionInfo.getArgs(), actionInfo.getResult(), actionInfo.getLog(), actionInfo.isSuccessful(), actionInfo.getCreateTime(), actionInfo.isFinished(), actionInfo.getFinishTime(), actionInfo.getProgress()); } public String getFilePath() { return filePath; } public void setFilePath(String filePath) { this.filePath = filePath; } public long getFileLength() { return fileLength; } public void setFileLength(long fileLength) { this.fileLength = fileLength; } public String getSrc() { return src; } public void setSrc(String src) { this.src = src; } public String getTarget() { return target; } public void setTarget(String target) { this.target = target; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CompactFileState.java
smart-common/src/main/java/org/smartdata/model/CompactFileState.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.io.Serializable; public class CompactFileState extends FileState implements Serializable { private FileContainerInfo fileContainerInfo; public CompactFileState(String path, FileContainerInfo fileContainerInfo) { super(path, FileType.COMPACT, FileStage.DONE); this.fileContainerInfo = fileContainerInfo; } public FileContainerInfo getFileContainerInfo() { return fileContainerInfo; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CmdletDispatchPolicy.java
smart-common/src/main/java/org/smartdata/model/CmdletDispatchPolicy.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * The policy defines which type of executor service should be used * to execute the given cmdlet. * */ public enum CmdletDispatchPolicy { ANY, // If not available then dispatch to other types PREFER_AGENT, PREFER_REMOTE_SSM, PREFER_LOCAL; // MUST_AGENT, // MUST_REMOTE_SSM, // MUST_LOCAL; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileDiff.java
smart-common/src/main/java/org/smartdata/model/FileDiff.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Objects; public class FileDiff { private long diffId; private long ruleId; private FileDiffType diffType; private String src; private Map<String, String> parameters; private FileDiffState state; private long createTime; public FileDiff() { this.createTime = System.currentTimeMillis(); this.parameters = new HashMap<>(); } public FileDiff(FileDiffType diffType) { this(); this.diffType = diffType; this.state = FileDiffState.PENDING; } public FileDiff(FileDiffType diffType, FileDiffState state) { this(); this.diffType = diffType; this.state = state; } public long getDiffId() { return diffId; } public void setDiffId(long diffId) { this.diffId = diffId; } public long getRuleId() { return ruleId; } public void setRuleId(long ruleId) { this.ruleId = ruleId; } public FileDiffType getDiffType() { return diffType; } public void setDiffType(FileDiffType diffType) { this.diffType = diffType; } public String getSrc() { return src; } public void setSrc(String src) { this.src = src; } public Map<String, String> getParameters() { return parameters; } public void setParameters(Map<String, String> parameters) { this.parameters = parameters; } public String getParametersJsonString() { Gson gson = new Gson(); return gson.toJson(parameters); } public void setParametersFromJsonString(String jsonParameters) { Gson gson = new Gson(); parameters = gson.fromJson(jsonParameters, new TypeToken<Map<String, String>>() { }.getType()); } public String getParametersString() { StringBuffer ret = new StringBuffer(); if (parameters.containsKey("-dest")) { ret.append(String.format(" -dest %s", parameters.get("-dest"))); parameters.remove("-dest"); } for (Iterator<Map.Entry<String, String>> it = parameters.entrySet().iterator(); it.hasNext();) { Map.Entry<String, String> entry = it.next(); ret.append(String.format(" %s %s", entry.getKey(), entry.getValue())); } return ret.toString(); } public FileDiffState getState() { return state; } public void setState(FileDiffState state) { this.state = state; } public long getCreateTime() { return createTime; } public void setCreateTime(long createTime) { this.createTime = createTime; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } FileDiff fileDiff = (FileDiff) o; return diffId == fileDiff.diffId && ruleId == fileDiff.ruleId && createTime == fileDiff.createTime && diffType == fileDiff.diffType && Objects.equals(src, fileDiff.src) && Objects.equals(parameters, fileDiff.parameters) && state == fileDiff.state; } @Override public int hashCode() { return Objects.hash(diffId, ruleId, diffType, src, parameters, state, createTime); } @Override public String toString() { return String.format( "FileDiff{diffId=%s, parameters=%s, src=%s, diffType=%s, state=%s, createTime=%s}", diffId, parameters, src, diffType, state.getValue(), createTime); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/StoragePolicy.java
smart-common/src/main/java/org/smartdata/model/StoragePolicy.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public class StoragePolicy { private byte sid; private String policyName; public StoragePolicy(byte sid, String policyName) { this.sid = sid; this.policyName = policyName; } public byte getSid() { return sid; } public void setSid(byte sid) { this.sid = sid; } public String getPolicyName() { return policyName; } public void setPolicyName(String policyName) { this.policyName = policyName; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } StoragePolicy that = (StoragePolicy) o; if (sid != that.sid) { return false; } return policyName != null ? policyName.equals(that.policyName) : that.policyName == null; } @Override public int hashCode() { int result = (int) sid; result = 31 * result + (policyName != null ? policyName.hashCode() : 0); return result; } @Override public String toString() { return String.format("StoragePolicy{sid=%s, policyName=\'%s\'}", sid, policyName); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CachedFileStatus.java
smart-common/src/main/java/org/smartdata/model/CachedFileStatus.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * Information maintained for a file cached in hdfs. */ public class CachedFileStatus { private long fid; private String path; private long fromTime; private long lastAccessTime; private int numAccessed; public CachedFileStatus() { } public CachedFileStatus( long fid, String path, long fromTime, long lastAccessTime, int numAccessed) { this.fid = fid; this.path = path; this.fromTime = fromTime; this.lastAccessTime = lastAccessTime; this.numAccessed = numAccessed; } public long getFid() { return fid; } public void setFid(long fid) { this.fid = fid; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public long getFromTime() { return fromTime; } public void setFromTime(long fromTime) { this.fromTime = fromTime; } public long getLastAccessTime() { return lastAccessTime; } public void setLastAccessTime(long lastAccessTime) { this.lastAccessTime = lastAccessTime; } public int getNumAccessed() { return numAccessed; } public void setNumAccessed(int numAccessed) { this.numAccessed = numAccessed; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } CachedFileStatus that = (CachedFileStatus) o; if (fid != that.fid) { return false; } if (fromTime != that.fromTime) { return false; } if (lastAccessTime != that.lastAccessTime) { return false; } if (numAccessed != that.numAccessed) { return false; } return path != null ? path.equals(that.path) : that.path == null; } @Override public int hashCode() { int result = (int) (fid ^ (fid >>> 32)); result = 31 * result + (path != null ? path.hashCode() : 0); result = 31 * result + (int) (fromTime ^ (fromTime >>> 32)); result = 31 * result + (int) (lastAccessTime ^ (lastAccessTime >>> 32)); result = 31 * result + numAccessed; return result; } @Override public String toString() { return String.format( "CachedFileStatus{fid=%s, path=\'%s\', fromTime=%s, lastAccessTime=%s, numAccessed=%s}", fid, path, fromTime, lastAccessTime, numAccessed); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ActionInfo.java
smart-common/src/main/java/org/smartdata/model/ActionInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; public class ActionInfo { // Old file id public static final String OLD_FILE_ID = "-oid"; private long actionId; private long cmdletId; private String actionName; private Map<String, String> args; private String result; private String log; // For action set flexibility private String execHost; private boolean successful; private long createTime; private boolean finished; private long finishTime; private float progress; public ActionInfo() { this.result = ""; this.log = ""; } public ActionInfo(long actionId, long cmdletId, String actionName, Map<String, String> args, String result, String log, boolean successful, long createTime, boolean finished, long finishTime, float progress) { this.actionId = actionId; this.cmdletId = cmdletId; this.actionName = actionName; this.args = args; this.result = result; this.log = log; this.execHost = ""; this.successful = successful; this.createTime = createTime; this.finished = finished; this.finishTime = finishTime; this.progress = progress; } public long getActionId() { return actionId; } public void setActionId(long actionId) { this.actionId = actionId; } public long getCmdletId() { return cmdletId; } public void setCmdletId(long cmdletId) { this.cmdletId = cmdletId; } public String getActionName() { return actionName; } public void setActionName(String actionName) { this.actionName = actionName; } public Map<String, String> getArgs() { return args; } public void setArgs(Map<String, String> args) { this.args = args; } public String getArgsJsonString() { Gson gson = new Gson(); return gson.toJson(args); } public void setArgsFromJsonString(String jsonArgs) { Gson gson = new Gson(); args = gson.fromJson(jsonArgs, new TypeToken<Map<String, String>>() { }.getType()); } // Applicable to some actions that need to create new file to replace // the old one. public void setOldFileIds(List<Long> oids) { getArgs().put(OLD_FILE_ID, toJsonString(oids)); } // Applicable to some actions that need to create new file to replace // the old one. public List<Long> getOldFileIds() { return fromJsonString( Optional.ofNullable(getArgs().get(OLD_FILE_ID)).orElse("")); } public static String toJsonString(List<Long> oids) { return new Gson().toJson(oids); } public static List<Long> fromJsonString(String oIdJson) { return new Gson().fromJson(oIdJson, new TypeToken<ArrayList<Long>>(){}.getType()); } public String getResult() { return result; } public void setResult(String result) { this.result = result; } public void appendResult(String result) { this.result += result; } public String getLog() { return log; } public void setLog(String log) { this.log = log; } public void appendLog(String log) { this.log += log; } public void appendLogLine(String logLine) { this.log += logLine + "\n"; } public boolean isSuccessful() { return successful; } public void setSuccessful(boolean successful) { this.successful = successful; } public long getCreateTime() { return createTime; } public void setCreateTime(long createTime) { this.createTime = createTime; } public boolean isFinished() { return finished; } public void setFinished(boolean finished) { this.finished = finished; } public long getFinishTime() { return finishTime; } public void setFinishTime(long finishTime) { this.finishTime = finishTime; } public float getProgress() { return progress; } public void setProgress(float progress) { this.progress = progress; } public String getExecHost() { return execHost; } public void setExecHost(String execHost) { this.execHost = execHost; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ActionInfo that = (ActionInfo) o; return actionId == that.actionId && cmdletId == that.cmdletId && successful == that.successful && createTime == that.createTime && finished == that.finished && finishTime == that.finishTime && Float.compare(that.progress, progress) == 0 && Objects.equals(actionName, that.actionName) && Objects.equals(args, that.args) && Objects.equals(result, that.result) && Objects.equals(log, that.log); } @Override public int hashCode() { return Objects.hash( actionId, cmdletId, actionName, args, result, log, successful, createTime, finished, finishTime, progress); } @Override public String toString() { return String.format( "ActionInfo{actionId=%s, cmdletId=%s, actionName=\'%s\', args=%s, result=\'%s\', " + "log=\'%s\', successful=%s, createTime=%s, finished=%s, progress=%s}", actionId, cmdletId, actionName, args, result, log, successful, createTime, finished, finishTime, progress); } public static Builder newBuilder() { return Builder.create(); } public static class Builder { private long actionId; private long cmdletId; private String actionName; private Map<String, String> args; private String result; private String log; private boolean successful; private long createTime; private boolean finished; private long finishTime; private float progress; public Builder setActionId(long actionId) { this.actionId = actionId; return this; } public Builder setCmdletId(long cmdletId) { this.cmdletId = cmdletId; return this; } public Builder setActionName(String actionName) { this.actionName = actionName; return this; } public Builder setArgs(Map<String, String> args) { this.args = args; return this; } public Builder setResult(String result) { this.result = result; return this; } public Builder setLog(String log) { this.log = log; return this; } public Builder setSuccessful(boolean successful) { this.successful = successful; return this; } public Builder setCreateTime(long createTime) { this.createTime = createTime; return this; } public Builder setFinished(boolean finished) { this.finished = finished; return this; } public Builder setFinishTime(long finishTime) { this.finishTime = finishTime; return this; } public Builder setProgress(float progress) { this.progress = progress; return this; } public static Builder create() { return new Builder(); } public ActionInfo build() { return new ActionInfo(actionId, cmdletId, actionName, args, result, log, successful, createTime, finished, finishTime, progress); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ActionDescriptor.java
smart-common/src/main/java/org/smartdata/model/ActionDescriptor.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * Provide info to action user. */ public class ActionDescriptor { private String actionName; private String displayName; // if not provided, use actionName instead private String usage; // Info about usage/arguments if any private String comment; // Provide detailed info if any public ActionDescriptor(String actionName, String displayName, String usage, String comment) { this.actionName = actionName; this.displayName = displayName; this.usage = usage; this.comment = comment; } public static Builder newBuilder() { return Builder.create(); } public String getActionName() { return actionName; } public void setActionName(String actionName) { this.actionName = actionName; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName) { this.displayName = displayName; } public String getUsage() { return usage; } public void setUsage(String usage) { this.usage = usage; } public String getComment() { return comment; } public void setComment(String comment) { this.comment = comment; } @Override public String toString() { return String.format( "ActionDescriptor{actionName=\'%s\', displayName=\'%s\', " + "displayName=\'%s\', usage=\'%s\', comment=\'%s\', comment=\'%s\'}", actionName, displayName, usage, comment); } public static class Builder { private String actionName; private String displayName; // if not provided, use actionName instead private String usage; // Info about usage/arguments if any private String comment; // Provide detailed info if any public Builder setActionName(String actionName) { this.actionName = actionName; return this; } public Builder setDisplayName(String displayName) { this.displayName = displayName; return this; } public Builder setUsage(String usage) { this.usage = usage; return this; } public Builder setComment(String comment) { this.comment = comment; return this; } public static Builder create() { return new Builder(); } public ActionDescriptor build() { return new ActionDescriptor(actionName, displayName, usage, comment); } @Override public String toString() { return String.format( "Builder{actionName=\'%s\', displayName=\'%s\', usage=\'%s\', comment=\'%s\'}", actionName, displayName, usage, comment); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/S3FileState.java
smart-common/src/main/java/org/smartdata/model/S3FileState.java
package org.smartdata.model; /** * FileState for normal S3 files. */ public class S3FileState extends FileState { public S3FileState(String path) { super(path, FileType.S3, FileStage.DONE); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/GlobalConfig.java
smart-common/src/main/java/org/smartdata/model/GlobalConfig.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class GlobalConfig { private long cid; private String propertyName; private String propertyValue; public GlobalConfig(int cid, String propertyName, String propertyValue) { this.cid = cid; this.propertyName = propertyName; this.propertyValue = propertyValue; } public GlobalConfig() { } public void setCid(long cid) { this.cid = cid; } public void setPropertyName(String propertyName) { this.propertyName = propertyName; } public void setPropertyValue(String propertyValue) { this.propertyValue = propertyValue; } public long getCid() { return cid; } public String getPropertyName() { return propertyName; } public String getPropertyValue() { return propertyValue; } @Override public String toString() { return String.format( "GlobalConfig{cid=%s, propertyName=\'%s\', propertyValue=\'%s\'}", cid, propertyName, propertyValue); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } GlobalConfig that = (GlobalConfig) o; return cid == that.cid && Objects.equals(propertyName, that.propertyName) && Objects.equals(propertyValue, that.propertyValue); } @Override public int hashCode() { return Objects.hash(cid, propertyName, propertyValue); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ErasureCodingPolicyInfo.java
smart-common/src/main/java/org/smartdata/model/ErasureCodingPolicyInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public class ErasureCodingPolicyInfo { private byte id; private String ecPolicyName; public ErasureCodingPolicyInfo(byte id, String ecPolicyName) { this.id = id; this.ecPolicyName = ecPolicyName; } public byte getID() { return id; } public void setID(byte id) { this.id = id; } public String getEcPolicyName() { return ecPolicyName; } public void setEcPolicyName(String policyName) { this.ecPolicyName = policyName; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ErasureCodingPolicyInfo that = (ErasureCodingPolicyInfo) o; if (id != that.id) { return false; } return ecPolicyName != null ? ecPolicyName.equals(that.ecPolicyName) : that.ecPolicyName == null; } @Override public int hashCode() { int result = (int) id; result = 11 * result + (ecPolicyName != null ? ecPolicyName.hashCode() : 0); return result; } @Override public String toString() { return String.format("StoragePolicy{id=%s, ecPolicyName=\'%s\'}", id, ecPolicyName); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/WhitelistHelper.java
smart-common/src/main/java/org/smartdata/model/WhitelistHelper.java
package org.smartdata.model; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartdata.conf.SmartConf; import java.util.Map; /** * It's a helper for whitelist function. It's used in action and rule submit process. * Especially, SmallFileScheduler also use this helper for distinguishing between * whitelist check and invalid small files exception. */ public class WhitelistHelper { private static final Logger LOG = LoggerFactory.getLogger(WhitelistHelper.class); /** * Check if whitelist is enabled. * @param conf * @return true/false */ public static boolean isEnabled(SmartConf conf) { return !conf.getCoverDir().isEmpty(); } /** * Check if the work path in the whitelist. * @param path * @param conf * @return true/false */ public static boolean isInWhitelist(String path, SmartConf conf) { String filePath = path.endsWith("/") ? path : path + "/"; for (String s : conf.getCoverDir()) { if (filePath.startsWith(s)) { LOG.debug("Path " + filePath + " is in whitelist."); return true; } } return false; } /** * Check if cmdlet in the whitelist. * @param cmdletDescriptor * @return true/false */ public static boolean isCmdletInWhitelist(CmdletDescriptor cmdletDescriptor) { SmartConf conf = new SmartConf(); int size = cmdletDescriptor.getActionSize(); for (int index = 0; index < size; index++) { String actionName = cmdletDescriptor.getActionName(index); Map<String, String> args = cmdletDescriptor.getActionArgs(index); //check in the SmallFileScheduler for small file action if (actionName.equals("compact") || actionName.equals("uncompact")) { continue; } else if (args.containsKey(CmdletDescriptor.HDFS_FILE_PATH)) { String filePath = args.get(CmdletDescriptor.HDFS_FILE_PATH); LOG.debug("WhiteList helper is checking path: " + filePath); if (!isInWhitelist(filePath, conf)) { return false; } } else { LOG.debug("This action text doesn't contain file path."); } } return true; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/DataNodeInfo.java
smart-common/src/main/java/org/smartdata/model/DataNodeInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class DataNodeInfo { private String uuid; private String hostname; private String rpcAddress; private long cacheCapacity; private long cacheUsed; private String location; public DataNodeInfo(String uuid, String hostname, String rpcAddress, long cacheCapacity, long cacheUsed, String location) { this.uuid = uuid; this.hostname = hostname; this.rpcAddress = rpcAddress; this.cacheCapacity = cacheCapacity; this.cacheUsed = cacheUsed; this.location = location; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DataNodeInfo that = (DataNodeInfo) o; return cacheCapacity == that.cacheCapacity && cacheUsed == that.cacheUsed && Objects.equals(uuid, that.uuid) && Objects.equals(hostname, that.hostname) && Objects.equals(rpcAddress, that.rpcAddress) && Objects.equals(location, that.location); } @Override public int hashCode() { return Objects.hash(uuid, hostname, rpcAddress, cacheCapacity, cacheUsed, location); } public String getUuid() { return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } public String getHostname() { return hostname; } public void setHostname(String hostname) { this.hostname = hostname; } public String getRpcAddress() { return rpcAddress; } public void setRpcAddress(String ip) { this.rpcAddress = rpcAddress; } public long getCacheCapacity() { return cacheCapacity; } public void setCacheCapacity(long cacheCapacity) { this.cacheCapacity = cacheCapacity; } public long getCacheUsed() { return cacheUsed; } public void setCacheUsed(long cacheUsed) { this.cacheUsed = cacheUsed; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } @Override public String toString() { return String.format( "DataNodeInfo{uuid=\'%s\', hostname=\'%s\', " + "rpcAddress=\'%s\', cache_capacity=%d, cache_used=%d, location=\'%s\'}", uuid, hostname, rpcAddress, cacheCapacity, cacheUsed, location); } public static Builder newBuilder() { return new Builder(); } public static class Builder { private String uuid; private String hostname; private String rpcAddress; private long cacheCapacity; private long cacheUsed; private String location; public Builder setUuid(String uuid) { this.uuid = uuid; return this; } public Builder setHostName(String hostname) { this.hostname = hostname; return this; } public Builder setRpcAddress(String rpcAddress) { this.rpcAddress = rpcAddress; return this; } public Builder setCacheCapacity(long cacheCapacity) { this.cacheCapacity = cacheCapacity; return this; } public Builder setCacheUsed(long cacheUsed) { this.cacheUsed = cacheUsed; return this; } public Builder setLocation(String location) { this.location = location; return this; } public DataNodeInfo build() { return new DataNodeInfo(uuid, hostname, rpcAddress, cacheCapacity, cacheUsed, location); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileInfoBatch.java
smart-common/src/main/java/org/smartdata/model/FileInfoBatch.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public class FileInfoBatch { private FileInfo[] fileInfos; private final int batchSize; private int index; public FileInfoBatch(int batchSize) { this.batchSize = batchSize; this.fileInfos = new FileInfo[batchSize]; this.index = 0; } public void add(FileInfo status) { this.fileInfos[index] = status; index += 1; } public boolean isFull() { return index == batchSize; } public int actualSize() { return this.index; } public FileInfo[] getFileInfos() { return this.fileInfos; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CmdletDescriptor.java
smart-common/src/main/java/org/smartdata/model/CmdletDescriptor.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import org.smartdata.utils.StringUtil; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; /** * CmdletDescriptor describes a cmdlet by parsing out action names and their * parameters like shell format. It does not including verifications like * whether the action is supported or the parameters are valid or not. * * <p>Cmdlet string should have the following format: * action1 [-option [value]] ... [; action2 [-option [value]] ...] */ public class CmdletDescriptor { public static final String RULE_ID = "-ruleId"; public static final String HDFS_FILE_PATH = "-file"; private Map<String, String> actionCommon = new HashMap<>(); private List<String> actionNames = new ArrayList<>(); private List<Map<String, String>> actionArgs = new ArrayList<>(); private String cmdletString = null; private long deferIntervalMs = 0L; // Not persist into DB now private static final String REG_ACTION_NAME = "^[a-zA-Z]+[a-zA-Z0-9_]*"; public CmdletDescriptor() { } public CmdletDescriptor(String cmdletString) throws ParseException { setCmdletString(cmdletString); } public CmdletDescriptor(String cmdletString, long ruleId) throws ParseException { setRuleId(ruleId); setCmdletString(cmdletString); } public String getCmdletString() { return cmdletString == null ? toCmdletString() : cmdletString; } public void setCmdletString(String cmdletString) throws ParseException { actionNames.clear(); actionArgs.clear(); this.cmdletString = cmdletString; parseCmdletString(cmdletString); } public void setCmdletParameter(String key, String value) { actionCommon.put(key, value); // After the setting, the cmdlet string should be changed. this.cmdletString = toCmdletString(); } public String getCmdletParameter(String key) { return actionCommon.get(key); } public long getRuleId() { String idStr = actionCommon.get(RULE_ID); try { return idStr == null ? 0 : Long.valueOf(idStr); } catch (Exception e) { return 0; } } public void setRuleId(long ruleId) { actionCommon.put(RULE_ID, "" + ruleId); } public void addAction(String actionName, Map<String, String> args) { actionNames.add(actionName); actionArgs.add(args); } public List<String> getActionNames() { List<String> ret = new ArrayList<>(actionNames.size()); ret.addAll(actionNames); return ret; } public String getActionName(int index) { return actionNames.get(index); } /** * Get a complete set of arguments including cmdlet common part. * @param index * @return */ public Map<String, String> getActionArgs(int index) { Map<String, String> map = new HashMap<>(); map.putAll(actionCommon); map.putAll(actionArgs.get(index)); return map; } public void addActionArg(int index, String key, String value) { actionArgs.get(index).put(key, value); } public String deleteActionArg(int index, String key) { Map<String, String> args = actionArgs.get(index); String value = null; if (args.containsKey(key)) { value = args.get(key); args.remove(key); } return value; } public int getActionSize() { return actionNames.size(); } /** * Construct an CmdletDescriptor from cmdlet string. * @param cmdString * @return * @throws ParseException */ public static CmdletDescriptor fromCmdletString(String cmdString) throws ParseException { CmdletDescriptor des = new CmdletDescriptor(cmdString); return des; } public String toCmdletString() { if (getActionSize() == 0) { return ""; } String cmds = getActionName(0) + " " + formatActionArguments(getActionArgs(0)); for (int i = 1; i < getActionSize(); i++) { cmds += " ; " + getActionName(i) + " " + formatActionArguments(getActionArgs(i)); } return cmds; } public boolean equals(CmdletDescriptor des) { if (des == null || this.getActionSize() != des.getActionSize()) { return false; } for (int i = 0; i < this.getActionSize(); i++) { if (!actionNames.get(i).equals(des.getActionName(i))) { return false; } Map<String, String> srcArgs = getActionArgs(i); Map<String, String> destArgs = des.getActionArgs(i); if (srcArgs.size() != destArgs.size()) { return false; } for (String key : srcArgs.keySet()) { if (!srcArgs.get(key).equals(destArgs.get(key))) { return false; } } } return true; } @Override public String toString() { return String.format( "CmdletDescriptor{actionCommon=%s, actionNames=%s, " + "actionArgs=%s, cmdletString=\'%s\'}", actionCommon, actionNames, actionArgs, cmdletString); } /** * To judge whether a same task is being tackled by SSM, we override * #hashCode and #equals to give this logical equal meaning: one ojbect * equals another if they have the same rule ID and same cmdlet string. */ @Override public int hashCode() { return Objects.hash(getRuleId(), getCmdletString()); } @Override public boolean equals(Object o) { if (o == null || this.getClass() != o.getClass()) { return false; } if (this == o) { return true; } CmdletDescriptor another = (CmdletDescriptor) o; return this.getRuleId() == another.getRuleId() && this.getCmdletString().equals(another.getCmdletString()); } private void parseCmdletString(String cmdlet) throws ParseException { if (cmdlet == null || cmdlet.length() == 0) { return; } char[] chars = (cmdlet + " ").toCharArray(); List<String> blocks = new ArrayList<String>(); char c; char[] token = new char[chars.length]; int tokenlen = 0; boolean sucing = false; boolean string = false; for (int idx = 0; idx < chars.length; idx++) { c = chars[idx]; if (c == ' ' || c == '\t') { if (string) { token[tokenlen++] = c; } if (sucing) { blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; sucing = false; } } else if (c == ';') { if (string) { throw new ParseException("Unexpected break of string", idx); } if (sucing) { blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; sucing = false; } verify(blocks, idx); } else if (c == '\\') { boolean tempAdded = false; if (sucing || string) { token[tokenlen++] = chars[++idx]; tempAdded = true; } if (!tempAdded && !sucing) { sucing = true; token[tokenlen++] = chars[++idx]; } } else if (c == '"') { if (sucing) { throw new ParseException("Unexpected \"", idx); } if (string) { if (chars[idx + 1] != '"') { string = false; blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; } else { idx++; } } else { string = true; } } else if (c == '\r' || c == '\n') { if (sucing) { sucing = false; blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; } if (string) { throw new ParseException("String cannot in more than one line", idx); } } else { if (string) { token[tokenlen++] = chars[idx]; } else { sucing = true; token[tokenlen++] = chars[idx]; } } } if (string) { throw new ParseException("Unexpect tail of string", chars.length); } if (blocks.size() > 0) { verify(blocks, chars.length); } } private void verify(List<String> blocks, int offset) throws ParseException { if (blocks.size() == 0) { throw new ParseException("Contains NULL action", offset); } if (blocks.get(0).startsWith(".")) { procMetaCmdlet(blocks, offset); blocks.clear(); return; } boolean matched = blocks.get(0).matches(REG_ACTION_NAME); if (!matched) { throw new ParseException("Invalid action name: " + blocks.get(0), offset); } String name = blocks.get(0); blocks.remove(0); Map<String, String> args = toArgMap(blocks); addAction(name, args); blocks.clear(); } private void procMetaCmdlet(List<String> blocks, int offset) throws ParseException { if (blocks.get(0).equals(".defer")) { long interval = -1; if (blocks.size() == 2) { interval = StringUtil.pharseTimeString(blocks.get(1)); } if (interval == -1) { throw new ParseException("Invalid meta cmdlet parameter: " + StringUtil.join(" ", blocks), offset); } deferIntervalMs = interval; return; } throw new ParseException("Unknown meta cmdlet: " + StringUtil.join(" ", blocks), offset); } public long getDeferIntervalMs() { return deferIntervalMs; } public void setDeferIntervalMs(long deferIntervalMs) { this.deferIntervalMs = deferIntervalMs; } public static List<String> toArgList(Map<String, String> args) { List<String> ret = new ArrayList<>(); for (String key : args.keySet()) { ret.add(key); ret.add(args.get(key)); } return ret; } public static Map<String, String> toArgMap(List<String> args) throws ParseException { Map<String, String> ret = new HashMap<>(); String opt = null; for (int i = 0; i < args.size(); i++) { String arg = args.get(i); if (arg.startsWith("-")) { if (opt == null) { opt = arg; } else { ret.put(opt, ""); opt = arg; } } else { if (opt == null) { throw new ParseException("Unknown action option name for value '" + arg + "'", 0); } else { ret.put(opt, arg); opt = null; } } } if (opt != null) { ret.put(opt, ""); } return ret; } private String formatActionArguments(String[] args) { if (args == null || args.length == 0) { return ""; } String ret = ""; for (String arg : args) { String rep = arg.replace("\\", "\\\\"); rep = rep.replace("\"", "\\\""); if (rep.matches(".*\\s+.*")) { ret += " \"" + rep + "\""; } else { ret += " " + rep; } } return ret.trim(); } private String formatActionArguments(Map<String, String> args) { if (args == null || args.size() == 0) { return ""; } String ret = ""; for (String key : args.keySet()) { ret += " " + formatItems(key) + " " + formatItems(args.get(key)); } return ret.trim(); } private String formatItems(String arg) { String rep = arg.replace("\\", "\\\\"); rep = rep.replace("\"", "\\\""); if (rep.matches(".*\\s+.*")) { return "\"" + rep + "\""; } else { return rep; } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileInfoMapper.java
smart-common/src/main/java/org/smartdata/model/FileInfoMapper.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.HashMap; import java.util.Map; import java.util.Set; public class FileInfoMapper { public static final String PATH = "path"; public static final String FID = "fid"; public static final String LENGTH = "length"; public static final String BLOCK_REPLICATION = "block_replication"; public static final String BLOCK_SIZE = "block_size"; public static final String MODIFICATION_TIME = "modification_time"; public static final String ACCESS_TIME = "access_time"; public static final String IS_DIR = "is_dir"; public static final String STORAGE_POLICY = "storage_policy"; public static final String OWNER = "owner"; public static final String GROUP = "group"; public static final String PERMISSION = "permission"; private Map<String, Object> attrMap; public FileInfoMapper(Map<String, Object> attrMap) { this.attrMap = attrMap; } public Set<String> getAttributesSpecified() { return attrMap.keySet(); } public String getPath() { return (String) attrMap.get(PATH); } public Long getFileId() { return (Long) attrMap.get(FID); } public Long getLength() { return (Long) attrMap.get(LENGTH); } public Boolean getIsdir() { return (Boolean) attrMap.get(IS_DIR); } public Short getBlock_replication() { return (Short) attrMap.get(BLOCK_REPLICATION); } public Long getBlocksize() { return (Long) attrMap.get(BLOCK_SIZE); } public Long getModification_time() { return (Long) attrMap.get(MODIFICATION_TIME); } public Long getAccess_time() { return (Long) attrMap.get(ACCESS_TIME); } public Short getPermission() { return (Short) attrMap.get(PERMISSION); } public String getOwner() { return (String) attrMap.get(OWNER); } public String getGroup(String group) { return (String) attrMap.get(GROUP); } public Byte getStoragePolicy(byte storagePolicy) { return (Byte) attrMap.get(STORAGE_POLICY); } public FileInfo toFileInfo() { FileInfo.Builder builder = FileInfo.newBuilder(); return builder.build(); } public static Builder newBuilder() { return new Builder(); } @Override public String toString() { return String.format("FileInfoMapper{attrMap=%s}", attrMap); } public static class Builder { private Map<String, Object> attrMap = new HashMap<>(); public Builder setPath(String path) { attrMap.put(FileInfoMapper.PATH, path); return this; } public Builder setFileId(long fileId) { attrMap.put(FileInfoMapper.FID, fileId); return this; } public Builder setLength(long length) { attrMap.put(FileInfoMapper.LENGTH, length); return this; } public Builder setIsdir(boolean isdir) { attrMap.put(FileInfoMapper.IS_DIR, isdir); return this; } public Builder setBlockReplication(short blockReplication) { attrMap.put(FileInfoMapper.BLOCK_REPLICATION, blockReplication); return this; } public Builder setBlocksize(long blocksize) { attrMap.put(FileInfoMapper.BLOCK_SIZE, blocksize); return this; } public Builder setModificationTime(long modificationTime) { attrMap.put(FileInfoMapper.MODIFICATION_TIME, modificationTime); return this; } public Builder setAccessTime(long accessTime) { attrMap.put(FileInfoMapper.ACCESS_TIME, accessTime); return this; } public Builder setPermission(short permission) { attrMap.put(FileInfoMapper.PERMISSION, permission); return this; } public Builder setOwner(String owner) { attrMap.put(FileInfoMapper.OWNER, owner); return this; } public Builder setGroup(String group) { attrMap.put(FileInfoMapper.GROUP, group); return this; } public Builder setStoragePolicy(byte storagePolicy) { attrMap.put(FileInfoMapper.STORAGE_POLICY, storagePolicy); return this; } public FileInfoMapper build() { return new FileInfoMapper(attrMap); } @Override public String toString() { return String.format("Builder{attrMap=%s}", attrMap); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/NormalFileState.java
smart-common/src/main/java/org/smartdata/model/NormalFileState.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * FileState for normal HDFS files. */ public class NormalFileState extends FileState { public NormalFileState(String path) { super(path, FileType.NORMAL, FileStage.DONE); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileContainerInfo.java
smart-common/src/main/java/org/smartdata/model/FileContainerInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.io.Serializable; public class FileContainerInfo implements Serializable { private String containerFilePath; private long offset; private long length; public FileContainerInfo(String containerFilePath, long offset, long length) { this.containerFilePath = containerFilePath; this.offset = offset; this.length = length; } public String getContainerFilePath() { return containerFilePath; } public void setContainerFilePath(String containerFilePath) { this.containerFilePath = containerFilePath; } public long getOffset() { return offset; } public void setOffset(long offset) { this.offset = offset; } public long getLength() { return length; } public void setLength(long length) { this.length = length; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileDiffState.java
smart-common/src/main/java/org/smartdata/model/FileDiffState.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.ArrayList; import java.util.List; public enum FileDiffState { PENDING(0), // Ready for execution RUNNING(1), // Still running APPLIED(2), MERGED(3), DELETED(4), FAILED(5); private int value; FileDiffState(int value) { this.value = value; } public static FileDiffState fromValue(int value) { for (FileDiffState r : values()) { if (value == r.getValue()) { return r; } } return null; } public int getValue() { return value; } public static List<FileDiffState> getUselessFileDiffState() { ArrayList<FileDiffState> states = new ArrayList<>(); states.add(FileDiffState.APPLIED); states.add(FileDiffState.DELETED); states.add(FileDiffState.FAILED); return states; } public static boolean isUselessFileDiff(FileDiffState state) { return state == APPLIED || state == DELETED || state == FAILED; } @Override public String toString() { return String.format("FileDiffState{value=%s} %s", value, super.toString()); } public static boolean isTerminalState(FileDiffState state) { return state.equals(APPLIED) || state.equals(MERGED) || state.equals(DELETED) || state.equals(FAILED); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/FileDiffType.java
smart-common/src/main/java/org/smartdata/model/FileDiffType.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public enum FileDiffType { CREATE(0), DELETE(1), RENAME(2), APPEND(3), METADATA(4), BASESYNC(5); private int value; FileDiffType(int value) { this.value = value; } public static FileDiffType fromValue(int value) { for (FileDiffType r : values()) { if (value == r.getValue()) { return r; } } return null; } public int getValue() { return value; } @Override public String toString() { return String.format("FileDiffType{value=%s} %s", value, super.toString()); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/UserInfo.java
smart-common/src/main/java/org/smartdata/model/UserInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class UserInfo { private final String name; // Needs to be encrypted by sha512 when inserted to Metastore. private final String password; public UserInfo(String name, String password) { this.name = name; this.password = password; } public String getUserName() { return name; } public String getUserPassword() { return password; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } UserInfo that = (UserInfo) o; return Objects.equals(name, that.name) && Objects.equals(password, that.password); } @Override public int hashCode() { return Objects.hash(name, password); } @Override public String toString() { return String.format("SystemInfo{user_name=\'%s\', user_password=\'%s\'}", name, password); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/LaunchAction.java
smart-common/src/main/java/org/smartdata/model/LaunchAction.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.io.Serializable; import java.util.Map; public class LaunchAction implements Serializable { private long actionId; private String actionType; private Map<String, String> args; public LaunchAction(long actionId, String actionType, Map<String, String> args) { this.actionId = actionId; this.actionType = actionType; this.args = args; } public long getActionId() { return actionId; } public void setActionId(long actionId) { this.actionId = actionId; } public String getActionType() { return actionType; } public void setActionType(String actionType) { this.actionType = actionType; } public Map<String, String> getArgs() { return args; } public void setArgs(Map<String, String> args) { this.args = args; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/ClusterConfig.java
smart-common/src/main/java/org/smartdata/model/ClusterConfig.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class ClusterConfig { private long cid; private String nodeName; private String configPath; public ClusterConfig(int cid, String nodeName, String configPath) { this.cid = cid; this.nodeName = nodeName; this.configPath = configPath; } public ClusterConfig() { } public void setCid(long cid) { this.cid = cid; } public void setNodeName(String nodeName) { this.nodeName = nodeName; } public void setConfig_path(String configPath) { this.configPath = configPath; } public long getCid() { return cid; } public String getNodeName() { return nodeName; } public String getConfigPath() { return configPath; } @Override public String toString() { return String.format( "ClusterConfig{cid=%s, nodeName=\'%s\', configPath=\'%s\'}", cid, nodeName, configPath); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ClusterConfig that = (ClusterConfig) o; return cid == that.cid && Objects.equals(nodeName, that.nodeName) && Objects.equals(configPath, that.configPath); } @Override public int hashCode() { return Objects.hash(cid, nodeName, configPath); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CmdletInfo.java
smart-common/src/main/java/org/smartdata/model/CmdletInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import org.apache.commons.lang.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Objects; public class CmdletInfo { private long cid; private long rid; private List<Long> aids; private CmdletState state; private String parameters; private long generateTime; private long stateChangedTime; private long deferedToTime; public CmdletInfo(long cid, long rid, CmdletState state, String parameters, long generateTime, long stateChangedTime) { this(cid, rid, state, parameters, generateTime, stateChangedTime, generateTime); } public CmdletInfo(long cid, long rid, CmdletState state, String parameters, long generateTime, long stateChangedTime, long deferedToTime) { this.cid = cid; this.rid = rid; this.state = state; this.parameters = parameters; this.generateTime = generateTime; this.stateChangedTime = stateChangedTime; this.deferedToTime = deferedToTime; this.aids = new ArrayList<>(); } public CmdletInfo(long cid, long rid, List<Long> aids, CmdletState state, String parameters, long generateTime, long stateChangedTime) { this(cid, rid, state, parameters, generateTime, stateChangedTime); this.aids = aids; } public CmdletInfo(long cid, long rid, List<Long> aids, CmdletState state, String parameters, long generateTime, long stateChangedTime, long deferedToTime) { this(cid, rid, state, parameters, generateTime, stateChangedTime, deferedToTime); this.aids = aids; } @Override public String toString() { return String.format("CmdletId -> [ %s ] {rid = %d, aids = %s, genTime = %d, " + "stateChangedTime = %d, state = %s, params = %s}", cid, rid, StringUtils.join(getAidsString(), ","), generateTime, stateChangedTime, state, parameters); } public void addAction(long aid) { aids.add(aid); } public List<Long> getAids() { return aids; } public List<String> getAidsString() { List<String> ret = new ArrayList<>(); for (Long aid : aids) { ret.add(String.valueOf(aid)); } return ret; } public long getCid() { return cid; } public void setCid(long cid) { this.cid = cid; } public long getRid() { return rid; } public void setRid(long rid) { this.rid = rid; } public void setAids(List<Long> aids) { this.aids = aids; } public CmdletState getState() { return state; } public void setState(CmdletState state) { this.state = state; } public void updateState(CmdletState state) { if (this.state != state) { this.state = state; this.stateChangedTime = System.currentTimeMillis(); } } public String getParameters() { return parameters; } public void setParameters(String parameters) { this.parameters = parameters; } public long getGenerateTime() { return generateTime; } public long getStateChangedTime() { return stateChangedTime; } public void setStateChangedTime(long stateChangedTime) { this.stateChangedTime = stateChangedTime; } public long getDeferedToTime() { return deferedToTime; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } CmdletInfo that = (CmdletInfo) o; return cid == that.cid && rid == that.rid && generateTime == that.generateTime && stateChangedTime == that.stateChangedTime && deferedToTime == that.deferedToTime && Objects.equals(aids, that.aids) && state == that.state && Objects.equals(parameters, that.parameters); } @Override public int hashCode() { return Objects.hash(cid, rid, aids, state, parameters, generateTime, stateChangedTime, deferedToTime); } public static Builder newBuilder() { return Builder.create(); } public static class Builder { private long cid; private long rid; private List<Long> aids; private CmdletState state; private String parameters; private long generateTime; private long stateChangedTime; private long deferedToTime; public static Builder create() { return new Builder(); } public Builder setCid(long cid) { this.cid = cid; return this; } public Builder setRid(long rid) { this.rid = rid; return this; } public Builder setAids(List<Long> aids) { this.aids = aids; return this; } public Builder setState(CmdletState state) { this.state = state; return this; } public Builder setParameters(String parameters) { this.parameters = parameters; return this; } public Builder setGenerateTime(long generateTime) { this.generateTime = generateTime; return this; } public Builder setStateChangedTime(long stateChangedTime) { this.stateChangedTime = stateChangedTime; return this; } public Builder setDeferedToTime(long deferedToTime) { this.deferedToTime = deferedToTime; return this; } public CmdletInfo build() { return new CmdletInfo(cid, rid, aids, state, parameters, generateTime, stateChangedTime, deferedToTime == 0 ? generateTime : deferedToTime); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/StorageCapacity.java
smart-common/src/main/java/org/smartdata/model/StorageCapacity.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public final class StorageCapacity { private String type; private Long timeStamp; private Long capacity; private Long free; public StorageCapacity(String type, Long timeStamp, Long capacity, Long free) { this.type = type; this.timeStamp = timeStamp; this.capacity = capacity; this.free = free; } public StorageCapacity(String type, Long capacity, Long free) { this.type = type; this.capacity = capacity; this.free = free; } public void setType(String type) { this.type = type; } public String getType() { return type; } public Long getCapacity() { return capacity; } public Long getTimeStamp() { return timeStamp; } public void setTimeStamp(Long timeStamp) { this.timeStamp = timeStamp; } public void addCapacity(long v) { capacity += v; } public Long getFree() { return free; } public Long getUsed() { return capacity - free; } public void addFree(long v) { free += v; } @Override public boolean equals(Object o) { // timeStamp not considered if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } StorageCapacity that = (StorageCapacity) o; if (type != null ? !type.equals(that.type) : that.type != null) { return false; } if (capacity != null ? !capacity.equals(that.capacity) : that.capacity != null) { return false; } return free != null ? free.equals(that.free) : that.free == null; } @Override public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + (capacity != null ? capacity.hashCode() : 0); result = 31 * result + (free != null ? free.hashCode() : 0); return result; } @Override public String toString() { return String.format( "StorageCapacity{type=\'%s\', capacity=%s, free=%s}", type, capacity, free); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/RuleState.java
smart-common/src/main/java/org/smartdata/model/RuleState.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; /** * The possible state that a rule can be in. */ public enum RuleState { ACTIVE(0), // functioning DRYRUN(1), // without execute the rule cmdlets DISABLED(2), // stop maintain info for the rule FINISHED(3), // for one-shot rule DELETED(4); private int value; private RuleState(int value) { this.value = value; } public static RuleState fromValue(int value) { for (RuleState r : values()) { if (value == r.getValue()) { return r; } } return null; } public static RuleState fromName(String name) { for (RuleState r : values()) { if (r.toString().equalsIgnoreCase(name)) { return r; } } return null; } public int getValue() { return value; } @Override public String toString() { return String.format("RuleState{value=%s} %s", value, super.toString()); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/Utilization.java
smart-common/src/main/java/org/smartdata/model/Utilization.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public class Utilization { private long timeStamp; private long total; private long used; public Utilization(long timeStamp, long total, long used) { this.timeStamp = timeStamp; this.total = total; this.used = used; } public long getTimeStamp() { return timeStamp; } public void setTimeStamp(long timeStamp) { this.timeStamp = timeStamp; } public long getTotal() { return total; } public void setTotal(long total) { this.total = total; } public long getUsed() { return used; } public void setUsed(long used) { this.used = used; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/DetailedRuleInfo.java
smart-common/src/main/java/org/smartdata/model/DetailedRuleInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; public class DetailedRuleInfo extends RuleInfo { public long baseProgress; public long runningProgress; public DetailedRuleInfo(RuleInfo ruleInfo) { // Init from ruleInfo super(ruleInfo.getId(), ruleInfo.getSubmitTime(), ruleInfo.getRuleText(), ruleInfo.getState(), ruleInfo.getNumChecked(), ruleInfo.getNumCmdsGen(), ruleInfo.getLastCheckTime()); } public long getBaseProgress() { return baseProgress; } public void setBaseProgress(long baseProgress) { this.baseProgress = baseProgress; } public long getRunningProgress() { return runningProgress; } public void setRunningProgress(long runningProgress) { this.runningProgress = runningProgress; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/BackUpInfo.java
smart-common/src/main/java/org/smartdata/model/BackUpInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Objects; public class BackUpInfo { private long rid; private String src; private String dest; private long period; // in milli-seconds public BackUpInfo(long rid, String src, String dest, long period) { this.rid = rid; this.src = src; this.dest = dest; this.period = period; } public BackUpInfo() { } public long getRid() { return rid; } public void setRid(long rid) { this.rid = rid; } public String getSrc() { return src; } public void setSrc(String src) { this.src = src; } public String getDest() { return dest; } public void setDest(String dest) { this.dest = dest; } public long getPeriod() { return period; } public void setPeriod(long period) { this.period = period; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BackUpInfo that = (BackUpInfo) o; return rid == that.rid && period == that.period && Objects.equals(src, that.src) && Objects.equals(dest, that.dest); } @Override public int hashCode() { return Objects.hash(rid, src, dest, period); } @Override public String toString() { return String.format( "BackUpInfo{rid=%s, src\'%s\', dest=\'%s\', period=%s}", rid, src, dest, period); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/CmdletState.java
smart-common/src/main/java/org/smartdata/model/CmdletState.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model; import java.util.Arrays; import java.util.List; /** * The possible state that a cmdlet can be in. */ public enum CmdletState { NOTINITED(0), PENDING(1), // Ready for schedule SCHEDULED(2), DISPATCHED(3), EXECUTING(4), // Still running PAUSED(5), DRYRUN(6), // TODO Don't Run, but keep status CANCELLED(7), DISABLED(8), // Disable this Cmdlet, kill all executing actions FAILED(9), // Running cmdlet failed DONE(10); // Execution successful private int value; private CmdletState(int value) { this.value = value; } public static CmdletState fromValue(int value) { for (CmdletState r : values()) { if (value == r.getValue()) { return r; } } return null; } public int getValue() { return value; } public static boolean isTerminalState(CmdletState state) { return getTerminalStates().contains(state); } public static List<CmdletState> getTerminalStates() { return Arrays.asList(CANCELLED, DISABLED, FAILED, DONE); } @Override public String toString() { return String.format("CmdletState{value=%s} %s", value, super.toString()); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/rule/RulePluginManager.java
smart-common/src/main/java/org/smartdata/model/rule/RulePluginManager.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.rule; import org.smartdata.model.RuleInfo; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class RulePluginManager { private static final RulePluginManager inst = new RulePluginManager(); private static List<RulePlugin> plugins = new ArrayList<>(); private RulePluginManager() { } public static RulePluginManager getInstance() { return inst; } public static synchronized void addPlugin(RulePlugin plugin) { if (!plugins.contains(plugin)) { plugins.add(plugin); } } public static synchronized void deletePlugin(RulePlugin plugin) { if (plugins.contains(plugin)) { plugins.remove(plugin); } } public static synchronized List<RulePlugin> getPlugins() { List<RulePlugin> copy = new ArrayList<>(); copy.addAll(plugins); return copy; } public static void onAddingNewRule(RuleInfo ruleInfo, TranslateResult tr) throws IOException { for (RulePlugin plugin : getPlugins()) { plugin.onAddingNewRule(ruleInfo, tr); } } public static void onNewRuleAdded(RuleInfo ruleInfo, TranslateResult tr) { for (RulePlugin plugin : getPlugins()) { plugin.onNewRuleAdded(ruleInfo, tr); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/rule/RulePlugin.java
smart-common/src/main/java/org/smartdata/model/rule/RulePlugin.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.rule; import org.smartdata.model.RuleInfo; import java.io.IOException; public interface RulePlugin { /** * Called when new rule is going to be added to SSM. * * @param ruleInfo id in ruleInfo is not valid when calling. * @param tr * @throws IOException the rule won't be added if exception. */ void onAddingNewRule(RuleInfo ruleInfo, TranslateResult tr) throws IOException; /** * Called when new rule has been added into SSM. * * @param ruleInfo * @param tr */ void onNewRuleAdded(RuleInfo ruleInfo, TranslateResult tr); }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/rule/RuleExecutorPluginManager.java
smart-common/src/main/java/org/smartdata/model/rule/RuleExecutorPluginManager.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.rule; import java.util.ArrayList; import java.util.List; public class RuleExecutorPluginManager { private static final RuleExecutorPluginManager inst = new RuleExecutorPluginManager(); private static List<RuleExecutorPlugin> plugins = new ArrayList<>(); private RuleExecutorPluginManager() { } public static RuleExecutorPluginManager getInstance() { return inst; } public static synchronized void addPlugin(RuleExecutorPlugin plugin) { if (!plugins.contains(plugin)) { plugins.add(plugin); } } public static synchronized void deletePlugin(RuleExecutorPlugin plugin) { if (plugins.contains(plugin)) { plugins.remove(plugin); } } public static synchronized List<RuleExecutorPlugin> getPlugins() { List<RuleExecutorPlugin> copy = new ArrayList<>(); copy.addAll(plugins); return copy; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/rule/RuleExecutorPlugin.java
smart-common/src/main/java/org/smartdata/model/rule/RuleExecutorPlugin.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.rule; import org.smartdata.model.CmdletDescriptor; import org.smartdata.model.RuleInfo; import java.util.List; public interface RuleExecutorPlugin { /** * Called just before an RuleExecutor been generated and submitted to * thread pool for execution. Only called once per instance. * * @param ruleInfo * @param tResult */ void onNewRuleExecutor(final RuleInfo ruleInfo, TranslateResult tResult); /** * Called just before rule executor begin to execute rule. * * @param ruleInfo * @param tResult * @return continue this execution if true. */ boolean preExecution(final RuleInfo ruleInfo, TranslateResult tResult); /** * Called after rule condition checked. * * @param objects the result of checking rule condition. * @return object list that will be used for Cmdlet submission. */ List<String> preSubmitCmdlet(final RuleInfo ruleInfo, List<String> objects); /** * Called right before the CmdletDescriptor been submitted to CmdletManager. * * @param descriptor * @return the descriptor that will be used to submit to CmdletManager */ CmdletDescriptor preSubmitCmdletDescriptor(final RuleInfo ruleInfo, TranslateResult tResult, CmdletDescriptor descriptor); /** * Called when an RuleExecutor exits. Called only once per instance. * * @param ruleInfo */ void onRuleExecutorExit(final RuleInfo ruleInfo); }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/rule/TimeBasedScheduleInfo.java
smart-common/src/main/java/org/smartdata/model/rule/TimeBasedScheduleInfo.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.rule; public class TimeBasedScheduleInfo { public static final long FOR_EVER = Long.MAX_VALUE; // If "at now" is used, start time is set to -1 in the parsing. // And it will be reset in trigger time. private long startTime; private long endTime; private long[] every; private long subScheduleTime; private long firstCheckTime; public TimeBasedScheduleInfo() { every = new long[1]; } public TimeBasedScheduleInfo(long startTime, long endTime, long[] every) { this.startTime = startTime; this.endTime = endTime; this.every = every.clone(); } public void setStartTime(long startTime) { this.startTime = startTime; } public void setEndTime(long endTime) { this.endTime = endTime; } public void setEvery(long[] every) { this.every = every.clone(); } public long getStartTime() { return startTime; } public long getEndTime() { return endTime; } public long[] getEvery() { return every; } public long getMinimalEvery() { if (every.length == 1) { return every[0]; } else { return every[0] > every[2] ? every[2] : every[0]; } } public long getBaseEvery() { return every[0]; } public boolean isOnce() { return startTime == endTime && startTime == 0 && every[0] == 0; } public boolean isOneShot() { return startTime == endTime && every[0] == 0; } public void setSubScheduleTime(long subScheduleTime) { this.subScheduleTime = subScheduleTime; } public long getSubScheduleTime() { return subScheduleTime; } public long getFirstCheckTime() { return firstCheckTime; } public void setFirstCheckTime(long firstCheckTime) { this.firstCheckTime = firstCheckTime; } public boolean isExecutable(long now) { return every.length <= 1 || every[0] == 0 || (now - firstCheckTime) % every[0] < every[1] + 50; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/rule/TranslateResult.java
smart-common/src/main/java/org/smartdata/model/rule/TranslateResult.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.rule; import org.smartdata.model.CmdletDescriptor; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Result of rule translation. A guide for execution. */ public class TranslateResult { private List<String> retColumns; private int retSqlIndex; private List<String> staticTempTables; // to be deleted after execution private List<String> sqlStatements; private Map<String, List<Object>> dynamicParameters; private TimeBasedScheduleInfo tbScheduleInfo; private CmdletDescriptor cmdDescriptor; private int[] condPosition; private List<String> globPathCheck = new ArrayList<>(); public TranslateResult(List<String> sqlStatements, List<String> tempTableNames, Map<String, List<Object>> dynamicParameters, int retSqlIndex, TimeBasedScheduleInfo tbScheduleInfo, CmdletDescriptor cmdDescriptor, int[] condPosition, List<String> globPathCheck) { this.sqlStatements = sqlStatements; this.staticTempTables = tempTableNames; this.dynamicParameters = dynamicParameters; this.retSqlIndex = retSqlIndex; this.tbScheduleInfo = tbScheduleInfo; this.cmdDescriptor = cmdDescriptor; this.condPosition = condPosition; this.globPathCheck = globPathCheck; } public CmdletDescriptor getCmdDescriptor() { return cmdDescriptor; } public void setCmdDescriptor(CmdletDescriptor cmdDescriptor) { this.cmdDescriptor = cmdDescriptor; } public void setSqlStatements(List<String> sqlStatements) { this.sqlStatements = sqlStatements; } public List<String> getSqlStatements() { return sqlStatements; } public List<String> getStaticTempTables() { return staticTempTables; } public List<Object> getParameter(String paramName) { return dynamicParameters.get(paramName); } public int getRetSqlIndex() { return retSqlIndex; } public TimeBasedScheduleInfo getTbScheduleInfo() { return tbScheduleInfo; } public boolean isTimeBased() { return tbScheduleInfo != null; } public int[] getCondPosition() { return condPosition; } public void setCondPosition(int[] condPosition) { this.condPosition = condPosition; } public List<String> getGlobPathCheck() { return globPathCheck; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/action/FileMovePlan.java
smart-common/src/main/java/org/smartdata/model/action/FileMovePlan.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.action; import com.google.gson.Gson; import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Plan of MoverScheduler to indicate block, source and target. */ public class FileMovePlan { public static final String MAX_CONCURRENT_MOVES = "maxConcurrentMoves"; public static final String MAX_NUM_RETRIES = "maxNumRetries"; // info of the namenode private URI namenode; // info of the file private String fileName; private long fileId; private boolean isDir; private boolean beingWritten; private long modificationTime; private long fileLength; private long fileLengthToMove; // length to move in file level private long sizeToMove; // total bytes to move private int blocksToMove; // number of file blocks private String currStoragePolicy; private String destStoragePolicy; // info of source datanode private List<String> sourceUuids; private List<String> sourceStoragetypes; // info of target datanode private List<String> targetIpAddrs; private List<Integer> targetXferPorts; private List<String> targetStorageTypes; // info of block private List<Long> blockIds; private Map<String, String> properties; public FileMovePlan(URI namenode, String fileName) { this.namenode = namenode; this.fileName = fileName; sourceUuids = new ArrayList<>(); sourceStoragetypes = new ArrayList<>(); targetIpAddrs = new ArrayList<>(); targetXferPorts = new ArrayList<>(); targetStorageTypes = new ArrayList<>(); properties = new HashMap<>(); blockIds = new ArrayList<>(); } public FileMovePlan() { this(null, null); } public void setFileName(String fileName) { this.fileName = fileName; } public void setNamenode(URI namenode) { this.namenode = namenode; } public void addPlan(long blockId, String srcDatanodeUuid, String srcStorageType, String dstDataNodeIpAddr, int dstDataNodeXferPort, String dstStorageType) { blockIds.add(blockId); sourceUuids.add(srcDatanodeUuid); sourceStoragetypes.add(srcStorageType); targetIpAddrs.add(dstDataNodeIpAddr); targetXferPorts.add(dstDataNodeXferPort); targetStorageTypes.add(dstStorageType); } public List<String> getSourceUuids() { return sourceUuids; } public List<String> getSourceStoragetypes() { return sourceStoragetypes; } public List<String> getTargetIpAddrs() { return targetIpAddrs; } public List<Integer> getTargetXferPorts() { return targetXferPorts; } public List<String> getTargetStorageTypes() { return targetStorageTypes; } public List<Long> getBlockIds() { return blockIds; } public String getFileName() { return fileName; } public URI getNamenode() { return namenode; } public void addProperty(String property, String value) { if (property != null) { properties.put(property, value); } } public String getPropertyValue(String property, String defaultValue) { if (properties.containsKey(property)) { return properties.get(property); } return defaultValue; } public int getPropertyValueInt(String property, int defaultValue) { String v = getPropertyValue(property, null); if (v == null) { return defaultValue; } return Integer.parseInt(v); } @Override public String toString() { Gson gson = new Gson(); return gson.toJson(this); } public static FileMovePlan fromJsonString(String jsonPlan) { Gson gson = new Gson(); return gson.fromJson(jsonPlan, FileMovePlan.class); } public long getFileLength() { return fileLength; } public void setFileLength(long fileLength) { this.fileLength = fileLength; } public long getSizeToMove() { return sizeToMove; } public void setSizeToMove(long sizeToMove) { this.sizeToMove = sizeToMove; } public void addSizeToMove(long size) { this.sizeToMove += size; } public int getBlocksToMove() { return blocksToMove; } public void incBlocksToMove() { this.blocksToMove += 1; } public long getFileLengthToMove() { return fileLengthToMove; } public void addFileLengthToMove(long fileLengthToMove) { this.fileLengthToMove += fileLengthToMove; } public boolean isDir() { return isDir; } public void setDir(boolean dir) { isDir = dir; } public boolean isBeingWritten() { return beingWritten; } public void setBeingWritten(boolean beingWritten) { this.beingWritten = beingWritten; } public long getModificationTime() { return modificationTime; } public void setModificationTime(long modificationTime) { this.modificationTime = modificationTime; } public String getCurrStoragePolicy() { return currStoragePolicy; } public void setCurrStoragePolicy(String currStoragePolicy) { this.currStoragePolicy = currStoragePolicy; } public String getDestStoragePolicy() { return destStoragePolicy; } public void setDestStoragePolicy(String destStoragePolicy) { this.destStoragePolicy = destStoragePolicy; } public long getFileId() { return fileId; } public void setFileId(long fileId) { this.fileId = fileId; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/action/ActionScheduler.java
smart-common/src/main/java/org/smartdata/model/action/ActionScheduler.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.action; import org.smartdata.model.ActionInfo; import org.smartdata.model.CmdletInfo; import org.smartdata.model.LaunchAction; import org.smartdata.protocol.message.LaunchCmdlet; import java.io.IOException; import java.util.List; public interface ActionScheduler { List<String> getSupportedActions(); /** * Called when new action submitted to CmdletManager. * * @param cmdletInfo info about the cmdlet which the action belongs to * @param actionInfo * @param actionIndex index of the action in cmdlet, * @return acceptable if true, or discard * @throws IOException */ boolean onSubmit(CmdletInfo cmdletInfo, ActionInfo actionInfo, int actionIndex) throws IOException; /** * Trying to schedule an action for Dispatch. * * @param cmdletInfo * @param actionInfo * @param cmdlet * @param action * @param actionIndex * @return */ ScheduleResult onSchedule(CmdletInfo cmdletInfo, ActionInfo actionInfo, LaunchCmdlet cmdlet, LaunchAction action, int actionIndex); /** * Called after and an Cmdlet get scheduled. * * @param actionInfo * @param result */ void postSchedule(CmdletInfo cmdletInfo, ActionInfo actionInfo, int actionIndex, ScheduleResult result); /** * Called just before dispatch for execution. * * @param action */ void onPreDispatch(LaunchCmdlet cmdlet, LaunchAction action, int actionIndex); /** * Called when action finished execution. * * @param actionInfo */ void onActionFinished(CmdletInfo cmdletInfo, ActionInfo actionInfo, int actionIndex); /** * Speculate whether timeout action is finished. */ boolean isSuccessfulBySpeculation(ActionInfo actionInfo); /** * Recover status, e.g., lock status. */ void recover(ActionInfo actionInfo); }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/action/CmdletScheduler.java
smart-common/src/main/java/org/smartdata/model/action/CmdletScheduler.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.action; // TODO: to be implemented public interface CmdletScheduler { boolean onSubmitCmdlet(); boolean postSubmitCmdlet(); ScheduleResult onSchedule(); void postSchedule(); void onDispatch(); void onActionMessage(); void onCmdletFinished(); }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/model/action/ScheduleResult.java
smart-common/src/main/java/org/smartdata/model/action/ScheduleResult.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.model.action; public enum ScheduleResult { SUCCESS, // OK for dispatch SUCCESS_NO_EXECUTION, // No need for further execution, mark the action finished successfully RETRY, // Need re-schedule later FAIL }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/exception/QueueFullException.java
smart-common/src/main/java/org/smartdata/exception/QueueFullException.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.exception; import java.io.IOException; /** * Denote a queue-full exception in SSM. */ public class QueueFullException extends IOException { static final long serialVersionUID = 7819031620146090155L; public QueueFullException() { super(); } public QueueFullException(String message) { super(message); } public QueueFullException(String message, Throwable throwable) { super(message, throwable); } public QueueFullException(Throwable throwable) { super(throwable); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/utils/StringUtil.java
smart-common/src/main/java/org/smartdata/utils/StringUtil.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.smartdata.utils; import com.google.common.hash.Hashing; import java.nio.charset.StandardCharsets; import java.text.ParseException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class StringUtil { private static final String DIR_SEP = "/"; private static final String[] GLOBS = new String[]{ "*", "?" }; public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) { if (elements == null) { return null; } StringBuilder sb = new StringBuilder(); Iterator<? extends CharSequence> it = elements.iterator(); if (!it.hasNext()) { return ""; } sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); } return sb.toString(); } public static String getBaseDir(String path) { if (path == null) { return null; } int last = path.lastIndexOf(DIR_SEP); if (last == -1) { return null; } int first = path.length(); for (String g : GLOBS) { int gIdx = path.indexOf(g); if (gIdx >= 0) { first = gIdx < first ? gIdx : first; } } last = path.substring(0, first).lastIndexOf(DIR_SEP); if (last == -1) { return null; } return path.substring(0, last + 1); } public static String globString2SqlLike(String str) { str = str.replace("*", "%"); str = str.replace("?", "_"); return str; } /** * Convert time string into milliseconds representation. * * @param str * @return -1 if error */ public static long pharseTimeString(String str) { long intval = 0L; str = str.trim(); Pattern p = Pattern.compile("([0-9]+)([a-z]+)"); Matcher m = p.matcher(str); int start = 0; while (m.find(start)) { String digStr = m.group(1); String unitStr = m.group(2); long value = 0; try { value = Long.parseLong(digStr); } catch (NumberFormatException e) { } switch (unitStr) { case "d": case "day": intval += value * 24 * 3600 * 1000; break; case "h": case "hour": intval += value * 3600 * 1000; break; case "m": case "min": intval += value * 60 * 1000; break; case "s": case "sec": intval += value * 1000; break; case "ms": intval += value; break; } start += m.group().length(); } return intval; } public static List<String> parseCmdletString(String cmdlet) throws ParseException { if (cmdlet == null || cmdlet.length() == 0) { return new ArrayList<>(); } char[] chars = (cmdlet + " ").toCharArray(); List<String> blocks = new ArrayList<String>(); char c; char[] token = new char[chars.length]; int tokenlen = 0; boolean sucing = false; boolean string = false; for (int idx = 0; idx < chars.length; idx++) { c = chars[idx]; if (c == ' ' || c == '\t') { if (string) { token[tokenlen++] = c; } if (sucing) { blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; sucing = false; } } else if (c == ';') { if (string) { throw new ParseException("Unexpected break of string", idx); } if (sucing) { blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; sucing = false; } } else if (c == '\\') { boolean tempAdded = false; if (sucing || string) { token[tokenlen++] = chars[++idx]; tempAdded = true; } if (!tempAdded && !sucing) { sucing = true; token[tokenlen++] = chars[++idx]; } } else if (c == '"') { if (sucing) { throw new ParseException("Unexpected \"", idx); } if (string) { if (chars[idx + 1] != '"') { string = false; blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; } else { idx++; } } else { string = true; } } else if (c == '\r' || c == '\n') { if (sucing) { sucing = false; blocks.add(String.valueOf(token, 0, tokenlen)); tokenlen = 0; } if (string) { throw new ParseException("String cannot in more than one line", idx); } } else { if (string) { token[tokenlen++] = chars[idx]; } else { sucing = true; token[tokenlen++] = chars[idx]; } } } if (string) { throw new ParseException("Unexpected tail of string", chars.length); } return blocks; } public static long parseToByte(String size) { String str = size.toUpperCase(); Long ret; long times = 1; Pattern p = Pattern.compile("([PTGMK]?B)|([PTGMK]+)"); Matcher m = p.matcher(str); String unit = ""; if (m.find()) { unit = m.group(); } str = str.substring(0, str.length() - unit.length()); switch (unit) { case "PB": case "P": times *= 1024L * 1024 * 1024 * 1024 * 1024; break; case "TB": case "T": times *= 1024L * 1024 * 1024 * 1024; break; case "GB": case "G": times *= 1024L * 1024 * 1024; break; case "MB": case "M": times *= 1024L * 1024; break; case "KB": case "K": times *= 1024L; break; } ret = Long.parseLong(str); return ret * times; } public static String toSHA512String(String password) { return Hashing.sha512().hashString(password, StandardCharsets.UTF_8).toString(); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/utils/SecurityUtil.java
smart-common/src/main/java/org/smartdata/utils/SecurityUtil.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * */ package org.smartdata.utils; import com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.security.UserGroupInformation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartdata.conf.SmartConf; import org.smartdata.conf.SmartConfKeys; import javax.security.auth.Subject; import javax.security.auth.kerberos.KerberosPrincipal; import javax.security.auth.login.AppConfigurationEntry; import javax.security.auth.login.Configuration; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; import java.io.File; import java.io.IOException; import java.security.Principal; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; /** * Jaas utilities for Smart login. */ public class SecurityUtil { public static final Logger LOG = LoggerFactory.getLogger(SecurityUtil.class); public static final boolean ENABLE_DEBUG = true; private static String getKrb5LoginModuleName() { return System.getProperty("java.vendor").contains("IBM") ? "com.ibm.security.auth.module.Krb5LoginModule" : "com.sun.security.auth.module.Krb5LoginModule"; } /** * Log a user in from a tgt ticket. * * @throws IOException */ public static synchronized Subject loginUserFromTgtTicket(String smartSecurity) throws IOException { TICKET_KERBEROS_OPTIONS.put("smartSecurity", smartSecurity); Subject subject = new Subject(); Configuration conf = new SmartJaasConf(); String confName = "ticket-kerberos"; LoginContext loginContext = null; try { loginContext = new LoginContext(confName, subject, null, conf); } catch (LoginException e) { throw new IOException("Fail to create LoginContext for " + e); } try { loginContext.login(); LOG.info("Login successful for user " + subject.getPrincipals().iterator().next().getName()); } catch (LoginException e) { throw new IOException("Login failure for " + e); } return loginContext.getSubject(); } /** * Smart Jaas config. */ static class SmartJaasConf extends Configuration { @Override public AppConfigurationEntry[] getAppConfigurationEntry(String name) { return new AppConfigurationEntry[]{ TICKET_KERBEROS_LOGIN}; } } private static final Map<String, String> BASIC_JAAS_OPTIONS = new HashMap<String, String>(); static { String jaasEnvVar = System.getenv("SMART_JAAS_DEBUG"); if (jaasEnvVar != null && "true".equalsIgnoreCase(jaasEnvVar)) { BASIC_JAAS_OPTIONS.put("debug", String.valueOf(ENABLE_DEBUG)); } } private static final Map<String, String> TICKET_KERBEROS_OPTIONS = new HashMap<String, String>(); static { TICKET_KERBEROS_OPTIONS.put("doNotPrompt", "true"); TICKET_KERBEROS_OPTIONS.put("useTgtTicket", "true"); TICKET_KERBEROS_OPTIONS.putAll(BASIC_JAAS_OPTIONS); } private static final AppConfigurationEntry TICKET_KERBEROS_LOGIN = new AppConfigurationEntry(getKrb5LoginModuleName(), AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL, TICKET_KERBEROS_OPTIONS); public static Subject loginUsingTicketCache(String principal) throws IOException { String ticketCache = System.getenv("KRB5CCNAME"); return loginUsingTicketCache(principal, ticketCache); } @VisibleForTesting static Subject loginUsingTicketCache( String principal, String ticketCacheFileName) throws IOException { Set<Principal> principals = new HashSet<Principal>(); principals.add(new KerberosPrincipal(principal)); Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>()); Configuration conf = useTicketCache(principal, ticketCacheFileName); String confName = "TicketCacheConf"; LoginContext loginContext = null; try { loginContext = new LoginContext(confName, subject, null, conf); } catch (LoginException e) { throw new IOException("Fail to create LoginContext for " + e); } try { loginContext.login(); LOG.info("Login successful for user " + subject.getPrincipals().iterator().next().getName()); } catch (LoginException e) { throw new IOException("Login failure for " + e); } return loginContext.getSubject(); } public static void loginUsingKeytab(SmartConf conf) throws IOException{ String keytabFilename = conf.get(SmartConfKeys.SMART_SERVER_KEYTAB_FILE_KEY); if (keytabFilename == null || keytabFilename.length() == 0) { throw new IOException("Running in secure mode, but config doesn't have a keytab"); } File keytabPath = new File(keytabFilename); String principalConfig = conf.get(SmartConfKeys.SMART_SERVER_KERBEROS_PRINCIPAL_KEY); String principal = org.apache.hadoop.security.SecurityUtil.getServerPrincipal(principalConfig, (String) null); try { SecurityUtil.loginUsingKeytab(keytabPath.getAbsolutePath(), principal); } catch (IOException e) { LOG.error("Fail to login using keytab. " + e); throw new IOException("Fail to login using keytab. " + e); } LOG.info("Login successful for user: " + principal); } public static void loginUsingKeytab(String keytabFilename, String principal) throws IOException { if (keytabFilename == null || keytabFilename.length() == 0) { throw new IOException("Running in secure mode, but config doesn't have a keytab"); } File keytabPath = new File(keytabFilename); try { UserGroupInformation.loginUserFromKeytab(principal, keytabPath.getAbsolutePath()); } catch (IOException e) { LOG.error("Fail to login using keytab. " + e); throw new IOException("Fail to login using keytab. " + e); } LOG.info("Login successful for user: " + principal); } public static Subject loginUsingKeytab( String principal, File keytabFile) throws IOException { Set<Principal> principals = new HashSet<Principal>(); principals.add(new KerberosPrincipal(principal)); Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>()); Configuration conf = useKeytab(principal, keytabFile); String confName = "KeytabConf"; LoginContext loginContext = null; try { loginContext = new LoginContext(confName, subject, null, conf); LOG.info("Login successful for user " + subject.getPrincipals().iterator().next().getName()); } catch (LoginException e) { throw new IOException("Faill to create LoginContext for " + e); } try { loginContext.login(); } catch (LoginException e) { throw new IOException("Login failure for " + e); } return loginContext.getSubject(); } public static Configuration useTicketCache(String principal, String ticketCacheFileName) { return new TicketCacheJaasConf(principal, ticketCacheFileName); } public static Configuration useKeytab(String principal, File keytabFile) { return new KeytabJaasConf(principal, keytabFile); } static class TicketCacheJaasConf extends Configuration { private String principal; private String ticketCacheFileName; TicketCacheJaasConf(String principal, String ticketCacheFileName) { this.principal = principal; this.ticketCacheFileName = ticketCacheFileName; } @Override public AppConfigurationEntry[] getAppConfigurationEntry(String name) { Map<String, String> options = new HashMap<String, String>(); options.put("principal", principal); options.put("storeKey", "false"); options.put("doNotPrompt", "false"); options.put("useTicketCache", "true"); options.put("renewTGT", "true"); options.put("refreshKrb5Config", "true"); options.put("isInitiator", "true"); if (ticketCacheFileName != null) { if (System.getProperty("java.vendor").contains("IBM")) { // The first value searched when "useDefaultCcache" is used. System.setProperty("KRB5CCNAME", ticketCacheFileName); } else { options.put("ticketCache", ticketCacheFileName); } } options.putAll(BASIC_JAAS_OPTIONS); return new AppConfigurationEntry[]{ new AppConfigurationEntry(getKrb5LoginModuleName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options)}; } } static class KeytabJaasConf extends Configuration { private String principal; private File keytabFile; KeytabJaasConf(String principal, File keytab) { this.principal = principal; this.keytabFile = keytab; } @Override public AppConfigurationEntry[] getAppConfigurationEntry(String name) { Map<String, String> options = new HashMap<String, String>(); options.put("keyTab", keytabFile.getAbsolutePath()); options.put("principal", principal); options.put("useKeyTab", "true"); options.put("storeKey", "true"); options.put("doNotPrompt", "true"); options.put("renewTGT", "false"); options.put("refreshKrb5Config", "true"); options.put("isInitiator", "true"); options.putAll(BASIC_JAAS_OPTIONS); return new AppConfigurationEntry[]{ new AppConfigurationEntry(getKrb5LoginModuleName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options)}; } } public static boolean isSecurityEnabled(SmartConf conf) { return conf.getBoolean(SmartConfKeys.SMART_SECURITY_ENABLE, false); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/utils/SsmHostUtils.java
smart-common/src/main/java/org/smartdata/utils/SsmHostUtils.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.utils; import java.net.InetAddress; import java.net.UnknownHostException; public class SsmHostUtils { public static String getHostNameOrIp() { String hi = System.getProperty("SSM_EXEC_HOST"); if (hi != null) { return hi; } try { hi = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { hi = "UNKNOWN_HOST"; } return hi; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/conf/ReconfigurableBase.java
smart-common/src/main/java/org/smartdata/conf/ReconfigurableBase.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.conf; import java.util.List; /** * This class helps to register all the properties of subclasses. */ public abstract class ReconfigurableBase implements Reconfigurable { public ReconfigurableBase() { List<String> properties = getReconfigurableProperties(); if (properties != null) { ReconfigurableRegistry.registReconfigurableProperty(properties, this); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/conf/ReconfigureException.java
smart-common/src/main/java/org/smartdata/conf/ReconfigureException.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.conf; public class ReconfigureException extends Exception { private String reason; private String property; private String newVal; private String oldVal; public ReconfigureException(String reason) { super(reason); this.reason = reason; this.property = null; this.newVal = null; this.oldVal = null; } public ReconfigureException(String property, String newVal, String oldVal) { super(formatMessage(property, newVal, oldVal)); this.property = property; this.newVal = newVal; this.oldVal = oldVal; } public ReconfigureException(String property, String newVal, String oldVal, Throwable cause) { super(formatMessage(property, newVal, oldVal), cause); this.property = property; this.newVal = newVal; this.oldVal = oldVal; } public String getReason() { return reason; } public String getProperty() { return property; } public String getNewValue() { return newVal; } public String getOldValue() { return oldVal; } private static String formatMessage(String property, String newVal, String oldVal) { return String.format("Failed to reconfig '%s' from '%s' to '%s'", property, oldVal, newVal); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/conf/SmartConf.java
smart-common/src/main/java/org/smartdata/conf/SmartConf.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.conf; import org.apache.hadoop.conf.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Console; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; /** * SSM related configurations as well as HDFS configurations. */ public class SmartConf extends Configuration { private static final Logger LOG = LoggerFactory.getLogger(SmartConf.class); private final List<String> ignoreList; private final List<String> coverList; // Include hosts configured in conf/agents and // hosts added dynamically (by `start-agent.sh --host $host`) private Set<String> agentHosts; private Set<String> serverHosts; public SmartConf() { Configuration.addDefaultResource("smart-default.xml"); Configuration.addDefaultResource("smart-site.xml"); Collection<String> ignoreDirs = this.getTrimmedStringCollection( SmartConfKeys.SMART_IGNORE_DIRS_KEY); Collection<String> fetchDirs = this.getTrimmedStringCollection( SmartConfKeys.SMART_COVER_DIRS_KEY); ignoreList = new ArrayList<>(); coverList = new ArrayList<>(); String tmpDir = this.get( SmartConfKeys.SMART_WORK_DIR_KEY, SmartConfKeys.SMART_WORK_DIR_DEFAULT); tmpDir = tmpDir + (tmpDir.endsWith("/") ? "" : "/"); ignoreList.add(tmpDir); for (String s : ignoreDirs) { ignoreList.add(s + (s.endsWith("/") ? "" : "/")); } for (String s : fetchDirs) { coverList.add(s + (s.endsWith("/") ? "" : "/")); } try { this.serverHosts = parseHost("servers", this); this.agentHosts = parseHost("agents", this); } catch (FileNotFoundException e) { // In some unit test, these files may be not given. So such exception is tolerable. LOG.warn("Could not get file named servers or agents to parse host."); } } public List<String> getCoverDir() { return coverList; } public List<String> getIgnoreDir() { return ignoreList; } public void setCoverDir(ArrayList<String> fetchDirs) { coverList.clear(); for (String s : fetchDirs) { coverList.add(s + (s.endsWith("/") ? "" : "/")); } } public void setIgnoreDir(ArrayList<String> ignoreDirs) { ignoreList.clear(); for (String s : ignoreDirs) { ignoreList.add(s + (s.endsWith("/") ? "" : "/")); } } public Set<String> parseHost(String fileName, SmartConf conf) throws FileNotFoundException { String hostName = ""; try { InetAddress address = InetAddress.getLocalHost(); hostName = address.getHostName(); } catch (UnknownHostException e) { e.printStackTrace(); } String filePath = conf.get(SmartConfKeys.SMART_CONF_DIR_KEY, SmartConfKeys.SMART_CONF_DIR_DEFAULT) + "/" + fileName; Scanner sc; HashSet<String> hostSet = new HashSet<>(); sc = new Scanner(new File(filePath)); while (sc != null && sc.hasNextLine()) { String entry = sc.nextLine().trim(); if (!entry.startsWith("#") && !entry.isEmpty()) { if (entry.equals("localhost")) { hostSet.add(hostName); } else { hostSet.add(entry); } } } return hostSet; } /** * Add host for newly launched standby server after SSM cluster * becomes active. */ public boolean addServerHosts(String hostname) { return serverHosts.add(hostname); } public Set<String> getServerHosts() { return serverHosts; } /** * Add host for newly launched agents after SSM cluster * becomes active. */ public boolean addAgentHost(String hostname) { return agentHosts.add(hostname); } public Set<String> getAgentHosts() { return agentHosts; } /** * Get password for druid by Configuration.getPassword(). */ public String getPasswordFromHadoop(String name) throws IOException { try { char[] pw = this.getPassword(name); if (pw == null) { return null; } return new String(pw); } catch (IOException err) { throw new IOException(err.getMessage(), err); } } public static void main(String[] args) { Console console = System.console(); try { Configuration.dumpConfiguration(new SmartConf(), console.writer()); } catch (IOException e) { e.printStackTrace(); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/conf/Reconfigurable.java
smart-common/src/main/java/org/smartdata/conf/Reconfigurable.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.conf; import java.util.List; /** * Properties that can be reconfigured at runtime. * Note: ReconfigurableRegistry should be used to register * the reconfigurable properties, otherwise won't get chance * to reconfigure. */ public interface Reconfigurable { /** * Called when the property's value is reconfigured. * @param property * @param newVal * @throws ReconfigureException */ void reconfigureProperty(String property, String newVal) throws ReconfigureException; /** * Return the reconfigurable properties that supported. * @return */ List<String> getReconfigurableProperties(); }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/conf/SmartConfKeys.java
smart-common/src/main/java/org/smartdata/conf/SmartConfKeys.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.conf; /** * This class contains the configure keys needed by SSM. */ public class SmartConfKeys { public static final String SMART_DFS_ENABLED = "smart.dfs.enabled"; public static final boolean SMART_DFS_ENABLED_DEFAULT = true; public static final String SMART_CONF_DIR_KEY = "smart.conf.dir"; public static final String SMART_HADOOP_CONF_DIR_KEY = "smart.hadoop.conf.path"; public static final String SMART_CONF_DIR_DEFAULT = "conf"; public static final String SMART_LOG_DIR_KEY = "smart.log.dir"; public static final String SMART_LOG_DIR_DEFAULT = "logs"; public static final String SMART_SERVICE_MODE_KEY = "smart.service.mode"; public static final String SMART_SERVICE_MODE_DEFAULT = "HDFS"; public static final String SMART_NAMESPACE_FETCHER_BATCH_KEY = "smart.namespace.fetcher.batch"; public static final int SMART_NAMESPACE_FETCHER_BATCH_DEFAULT = 500; public static final String SMART_DFS_NAMENODE_RPCSERVER_KEY = "smart.dfs.namenode.rpcserver"; // Configure keys for HDFS public static final String SMART_NAMESPACE_FETCHER_IGNORE_UNSUCCESSIVE_INOTIFY_EVENT_KEY = "smart.namespace.fetcher.ignore.unsuccessive.inotify.event"; public static final boolean SMART_NAMESPACE_FETCHER_IGNORE_UNSUCCESSIVE_INOTIFY_EVENT_DEFAULT = false; public static final String SMART_NAMESPACE_FETCHER_PRODUCERS_NUM_KEY = "smart.namespace.fetcher.producers.num"; public static final int SMART_NAMESPACE_FETCHER_PRODUCERS_NUM_DEFAULT = 3; public static final String SMART_NAMESPACE_FETCHER_CONSUMERS_NUM_KEY = "smart.namespace.fetcher.consumers.num"; public static final int SMART_NAMESPACE_FETCHER_CONSUMERS_NUM_DEFAULT = 3; // Configure keys for Alluxio public static final String SMART_ALLUXIO_MASTER_HOSTNAME_KEY = "smart.alluxio.master.hostname"; public static final String SMART_ALLUXIO_CONF_DIR_KEY = "smart.alluxio.conf.dir"; public static final String SMART_ALLUXIO_MASTER_JOURNAL_DIR_KEY = "smart.alluxio.master.journal.dir"; // SSM public static final String SMART_SERVER_RPC_ADDRESS_KEY = "smart.server.rpc.address"; public static final String SMART_SERVER_RPC_ADDRESS_DEFAULT = "0.0.0.0:7042"; public static final String SMART_SERVER_RPC_HANDLER_COUNT_KEY = "smart.server.rpc.handler.count"; public static final int SMART_SERVER_RPC_HANDLER_COUNT_DEFAULT = 80; public static final String SMART_SERVER_HTTP_ADDRESS_KEY = "smart.server.http.address"; public static final String SMART_SERVER_HTTP_ADDRESS_DEFAULT = "0.0.0.0:7045"; public static final String SMART_SERVER_HTTPS_ADDRESS_KEY = "smart.server.https.address"; public static final String SMART_SECURITY_ENABLE = "smart.security.enable"; public static final String SMART_SERVER_KEYTAB_FILE_KEY = "smart.server.keytab.file"; public static final String SMART_SERVER_KERBEROS_PRINCIPAL_KEY = "smart.server.kerberos.principal"; public static final String SMART_AGENT_KEYTAB_FILE_KEY = "smart.agent.keytab.file"; public static final String SMART_AGENT_KERBEROS_PRINCIPAL_KEY = "smart.agent.kerberos.principal"; public static final String SMART_SECURITY_CLIENT_PROTOCOL_ACL = "smart.security.client.protocol.acl"; public static final String SMART_SECURITY_ADMIN_PROTOCOL_ACL = "smart.security.admin.protocol.acl"; public static final String SMART_METASTORE_DB_URL_KEY = "smart.metastore.db.url"; // Password which get from hadoop credentialProvider used for metastore connect public static final String SMART_METASTORE_PASSWORD = "smart.metastore.password"; // How many bytes that one character takes up, default value is 1. public static final String SMART_METASTORE_CHARACTER_TAKEUP_BYTES_KEY = "smart.metastore.character.takeup.bytes"; public static final int SMART_METASTORE_CHARACTER_TAKEUP_BYTES_DEFAULT = 1; // StatesManager // RuleManager public static final String SMART_RULE_EXECUTORS_KEY = "smart.rule.executors"; public static final int SMART_RULE_EXECUTORS_DEFAULT = 5; public static final String SMART_CMDLET_EXECUTORS_KEY = "smart.cmdlet.executors"; public static final int SMART_CMDLET_EXECUTORS_DEFAULT = 10; public static final String SMART_DISPATCH_CMDLETS_EXTRA_NUM_KEY = "smart.dispatch.cmdlets.extra.num"; public static final int SMART_DISPATCH_CMDLETS_EXTRA_NUM_DEFAULT = 10; // Keep it only for test public static final String SMART_ENABLE_ZEPPELIN_WEB = "smart.zeppelin.web.enable"; public static final boolean SMART_ENABLE_ZEPPELIN_WEB_DEFAULT = true; // Cmdlets public static final String SMART_CMDLET_MAX_NUM_PENDING_KEY = "smart.cmdlet.max.num.pending"; public static final int SMART_CMDLET_MAX_NUM_PENDING_DEFAULT = 20000; public static final String SMART_CMDLET_HIST_MAX_NUM_RECORDS_KEY = "smart.cmdlet.hist.max.num.records"; public static final int SMART_CMDLET_HIST_MAX_NUM_RECORDS_DEFAULT = 100000; public static final String SMART_CMDLET_HIST_MAX_RECORD_LIFETIME_KEY = "smart.cmdlet.hist.max.record.lifetime"; public static final String SMART_CMDLET_HIST_MAX_RECORD_LIFETIME_DEFAULT = "30day"; public static final String SMART_CMDLET_CACHE_BATCH = "smart.cmdlet.cache.batch"; public static final int SMART_CMDLET_CACHE_BATCH_DEFAULT = 600; public static final String SMART_CMDLET_MOVER_MAX_CONCURRENT_BLOCKS_PER_SRV_INST_KEY = "smart.cmdlet.mover.max.concurrent.blocks.per.srv.inst"; public static final int SMART_CMDLET_MOVER_MAX_CONCURRENT_BLOCKS_PER_SRV_INST_DEFAULT = 0; // Schedulers public static final String SMART_COPY_SCHEDULER_BASE_SYNC_BATCH = "smart.copy.scheduler.base.sync.batch"; public static final int SMART_COPY_SCHEDULER_BASE_SYNC_BATCH_DEFAULT = 500; public static final String SMART_COPY_SCHEDULER_CHECK_INTERVAL = "smart.copy.scheduler.check.interval"; public static final int SMART_COPY_SCHEDULER_CHECK_INTERVAL_DEFAULT = 500; public static final String SMART_FILE_DIFF_MAX_NUM_RECORDS_KEY = "smart.file.diff.max.num.records"; public static final int SMART_FILE_DIFF_MAX_NUM_RECORDS_DEFAULT = 10000; // Dispatcher public static final String SMART_CMDLET_DISPATCHER_LOG_DISP_RESULT_KEY = "smart.cmdlet.dispatcher.log.disp.result"; public static final boolean SMART_CMDLET_DISPATCHER_LOG_DISP_RESULT_DEFAULT = false; public static final String SMART_CMDLET_DISPATCHERS_KEY = "smart.cmdlet.dispatchers"; public static final int SMART_CMDLET_DISPATCHERS_DEFAULT = 3; public static final String SMART_CMDLET_DISPATCHER_LOG_DISP_METRICS_INTERVAL_KEY = "smart.cmdlet.dispatcher.log.disp.metrics.interval"; // in ms public static final int SMART_CMDLET_DISPATCHER_LOG_DISP_METRICS_INTERVAL_DEFAULT = 5000; // Action public static final String SMART_ACTION_MOVE_THROTTLE_MB_KEY = "smart.action.move.throttle.mb"; public static final long SMART_ACTION_MOVE_THROTTLE_MB_DEFAULT = 0L; // 0 means unlimited public static final String SMART_ACTION_COPY_THROTTLE_MB_KEY = "smart.action.copy.throttle.mb"; public static final long SMART_ACTION_COPY_THROTTLE_MB_DEFAULT = 0L; // 0 means unlimited public static final String SMART_ACTION_EC_THROTTLE_MB_KEY = "smart.action.ec.throttle.mb"; public static final long SMART_ACTION_EC_THROTTLE_MB_DEFAULT = 0L; public static final String SMART_ACTION_LOCAL_EXECUTION_DISABLED_KEY = "smart.action.local.execution.disabled"; public static final boolean SMART_ACTION_LOCAL_EXECUTION_DISABLED_DEFAULT = false; // SmartAgent public static final String SMART_AGENT_MASTER_PORT_KEY = "smart.agent.master.port"; public static final int SMART_AGENT_MASTER_PORT_DEFAULT = 7051; public static final String SMART_AGENT_PORT_KEY = "smart.agent.port"; public static final int SMART_AGENT_PORT_DEFAULT = 7048; /** Do NOT configure the following two options manually. They are set by the boot scripts. **/ public static final String SMART_AGENT_MASTER_ADDRESS_KEY = "smart.agent.master.address"; public static final String SMART_AGENT_ADDRESS_KEY = "smart.agent.address"; // Small File Compact public static final String SMART_COMPACT_BATCH_SIZE_KEY = "smart.compact.batch.size"; public static final int SMART_COMPACT_BATCH_SIZE_DEFAULT = 200; public static final String SMART_COMPACT_CONTAINER_FILE_THRESHOLD_MB_KEY = "smart.compact.container.file.threshold.mb"; public static final long SMART_COMPACT_CONTAINER_FILE_THRESHOLD_MB_DEFAULT = 1024; // SmartClient // Common /** * Namespace, access info and other info related to files under these dirs will be ignored. * Clients will not report access event of these files to SSM. * For more than one directories, they should be separated by ",". */ public static final String SMART_IGNORE_DIRS_KEY = "smart.ignore.dirs"; /** * Namespace, access info and other info only related to files under these dirs will be tackled. * For more than one directories, they should be separated by ",". */ public static final String SMART_COVER_DIRS_KEY = "smart.cover.dirs"; public static final String SMART_WORK_DIR_KEY = "smart.work.dir"; public static final String SMART_WORK_DIR_DEFAULT = "/system/ssm/"; // Target cluster public static final String SMART_STORAGE_INFO_UPDATE_INTERVAL_KEY = "smart.storage.info.update.interval"; public static final int SMART_STORAGE_INFO_UPDATE_INTERVAL_DEFAULT = 60; public static final String SMART_STORAGE_INFO_SAMPLING_INTERVALS_KEY = "smart.storage.info.sampling.intervals"; public static final String SMART_STORAGE_INFO_SAMPLING_INTERVALS_DEFAULT = "60s,60;1hour,60;1day"; public static final String SMART_TOP_HOT_FILES_NUM_KEY = "smart.top.hot.files.num"; public static final int SMART_TOP_HOT_FILES_NUM_DEFAULT = 200; //Status report public static final String SMART_STATUS_REPORT_PERIOD_KEY = "smart.status.report.period"; public static final int SMART_STATUS_REPORT_PERIOD_DEFAULT = 10; public static final String SMART_STATUS_REPORT_PERIOD_MULTIPLIER_KEY = "smart.status.report.period.multiplier"; public static final int SMART_STATUS_REPORT_PERIOD_MULTIPLIER_DEFAULT = 50; public static final String SMART_STATUS_REPORT_RATIO_KEY = "smart.status.report.ratio"; public static final double SMART_STATUS_REPORT_RATIO_DEFAULT = 0.2; // Compression public static final String SMART_COMPRESSION_CODEC = "smart.compression.codec"; public static final String SMART_COMPRESSION_CODEC_DEFAULT = "Zlib"; public static final String SMART_COMPRESSION_MAX_SPLIT = "smart.compression.max.split"; public static final int SMART_COMPRESSION_MAX_SPLIT_DEFAULT = 1000; // Enable current report or not in SSM HA mode. public static final String SMART_CLIENT_CONCURRENT_REPORT_ENABLED = "smart.client.concurrent.report.enabled"; public static final boolean SMART_CLIENT_CONCURRENT_REPORT_ENABLED_DEFAULT = true; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/conf/ReconfigurableRegistry.java
smart-common/src/main/java/org/smartdata/conf/ReconfigurableRegistry.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.conf; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; import java.util.Set; public class ReconfigurableRegistry { private static ListMultimap<String, Reconfigurable> reconfMap = ArrayListMultimap.create(); public static final Logger LOG = LoggerFactory.getLogger(ReconfigurableRegistry.class); public static void registReconfigurableProperty(String property, Reconfigurable reconfigurable) { synchronized (reconfMap) { reconfMap.put(property, reconfigurable); } } public static void registReconfigurableProperty(List<String> properties, Reconfigurable reconfigurable) { synchronized (reconfMap) { for (String p : properties) { reconfMap.put(p, reconfigurable); } } } public static void applyReconfigurablePropertyValue(String property, String value) { for (Reconfigurable c : getReconfigurables(property)) { try { c.reconfigureProperty(property, value); } catch (Exception e) { LOG.error("", e); // ignore and continue; } } } /** * Return modules interest in the property. * @param property * @return */ public static List<Reconfigurable> getReconfigurables(String property) { synchronized (reconfMap) { return reconfMap.get(property); } } /** * Return configurable properties in system. * @return */ public static Set<String> getAllReconfigurableProperties() { synchronized (reconfMap) { return reconfMap.keySet(); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/metaservice/MetaService.java
smart-common/src/main/java/org/smartdata/metaservice/MetaService.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.metaservice; public interface MetaService { }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/metaservice/CmdletMetaService.java
smart-common/src/main/java/org/smartdata/metaservice/CmdletMetaService.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.metaservice; import org.smartdata.model.CmdletInfo; import org.smartdata.model.CmdletState; import java.util.List; public interface CmdletMetaService extends MetaService { CmdletInfo getCmdletById(long cid) throws MetaServiceException; List<CmdletInfo> getCmdlets(String cidCondition, String ridCondition, CmdletState state) throws MetaServiceException; boolean updateCmdlet(long cid, CmdletState state) throws MetaServiceException; boolean updateCmdlet(long cid, String parameters, CmdletState state) throws MetaServiceException; void deleteCmdlet(long cid) throws MetaServiceException; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/metaservice/MetaServiceException.java
smart-common/src/main/java/org/smartdata/metaservice/MetaServiceException.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.metaservice; public class MetaServiceException extends Exception { public MetaServiceException(String errorMsg) { super(errorMsg); } public MetaServiceException(String errorMsg, Throwable throwable) { super(errorMsg, throwable); } public MetaServiceException(Throwable throwable) { super(throwable); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/metaservice/BackupMetaService.java
smart-common/src/main/java/org/smartdata/metaservice/BackupMetaService.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.metaservice; import org.smartdata.model.BackUpInfo; import java.util.List; public interface BackupMetaService extends MetaService { List<BackUpInfo> listAllBackUpInfo() throws MetaServiceException; BackUpInfo getBackUpInfo(long rid) throws MetaServiceException; void deleteAllBackUpInfo() throws MetaServiceException; void deleteBackUpInfo(long rid) throws MetaServiceException; void insertBackUpInfo(BackUpInfo backUpInfo) throws MetaServiceException; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/metaservice/CopyMetaService.java
smart-common/src/main/java/org/smartdata/metaservice/CopyMetaService.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.metaservice; import org.smartdata.model.FileDiff; import org.smartdata.model.FileDiffState; import java.util.List; public interface CopyMetaService extends MetaService { long insertFileDiff(FileDiff fileDiff) throws MetaServiceException; List<FileDiff> getPendingDiff() throws MetaServiceException; List<FileDiff> getPendingDiff(long rid) throws MetaServiceException; boolean updateFileDiff(long did, FileDiffState state) throws MetaServiceException; void deleteAllFileDiff() throws MetaServiceException; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/SmartClientProtocol.java
smart-common/src/main/java/org/smartdata/protocol/SmartClientProtocol.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol; import org.apache.hadoop.security.KerberosInfo; import org.smartdata.conf.SmartConfKeys; import org.smartdata.metrics.FileAccessEvent; import org.smartdata.model.FileState; import java.io.IOException; /** * Interface between SmartClient and SmartServer. */ @KerberosInfo( serverPrincipal = SmartConfKeys.SMART_SERVER_KERBEROS_PRINCIPAL_KEY) public interface SmartClientProtocol { void reportFileAccessEvent(FileAccessEvent event) throws IOException; FileState getFileState(String filePath) throws IOException; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/SmartAdminProtocol.java
smart-common/src/main/java/org/smartdata/protocol/SmartAdminProtocol.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol; import org.apache.hadoop.security.KerberosInfo; import org.smartdata.SmartServiceState; import org.smartdata.conf.SmartConfKeys; import org.smartdata.model.ActionDescriptor; import org.smartdata.model.ActionInfo; import org.smartdata.model.CmdletInfo; import org.smartdata.model.CmdletState; import org.smartdata.model.RuleInfo; import org.smartdata.model.RuleState; import java.io.IOException; import java.util.List; @KerberosInfo( serverPrincipal = SmartConfKeys.SMART_SERVER_KERBEROS_PRINCIPAL_KEY) public interface SmartAdminProtocol { SmartServiceState getServiceState() throws IOException; long submitRule(String rule, RuleState initState) throws IOException; /** * Check if it is a valid rule. * @param rule * @throws IOException if not valid */ void checkRule(String rule) throws IOException; /** * Get information about the given rule. * @param ruleID * @return * @throws IOException */ RuleInfo getRuleInfo(long ruleID) throws IOException; /** * List rules in SSM. * TODO: maybe we can return only info about rules in certain state. * @return * @throws IOException */ List<RuleInfo> listRulesInfo() throws IOException; /** * Delete a rule in SSM. if dropPendingCmdlets equals false then the rule * record will still be kept in Table 'rules', the record will be deleted * sometime later. * * @param ruleID * @param dropPendingCmdlets pending cmdlets triggered by the rule will be * discarded if true. * @throws IOException */ void deleteRule(long ruleID, boolean dropPendingCmdlets) throws IOException; void activateRule(long ruleID) throws IOException; void disableRule(long ruleID, boolean dropPendingCmdlets) throws IOException; /** * Get information about the given cmdlet. * @param cmdletID * @return CmdletInfo * @throws IOException */ CmdletInfo getCmdletInfo(long cmdletID) throws IOException; /** * List cmdlets in SSM. * @param ruleID * @param cmdletState * @return All cmdletInfos that satisfy requirement * @throws IOException */ List<CmdletInfo> listCmdletInfo(long ruleID, CmdletState cmdletState) throws IOException; /** * Get information about the given cmdlet. * @param cmdletID * @return CmdletInfo * @throws IOException */ void activateCmdlet(long cmdletID) throws IOException; /** * Disable Cmdlet, if cmdlet is PENDING then mark as DISABLE * if cmdlet is EXECUTING then kill all actions unfinished * then mark as DISABLE, if cmdlet is DONE then do nothing. * @param cmdletID * @throws IOException */ void disableCmdlet(long cmdletID) throws IOException; /** * Delete Cmdlet from DB and Cache. If cmdlet is in Cache, * then disable it. * @param cmdletID * @throws IOException */ void deleteCmdlet(long cmdletID) throws IOException; /** * Query action info using action id. * @param actionID * @return * @throws IOException */ ActionInfo getActionInfo(long actionID) throws IOException; /** * Return info of actions newly generated. * @param maxNumActions maximum number of actions * @return * @throws IOException */ List<ActionInfo> listActionInfoOfLastActions(int maxNumActions) throws IOException; /** * Submit a cmdlet to server. * @param cmd separate actions with ';' * @return cmdlet id if success * @throws IOException */ long submitCmdlet(String cmd) throws IOException; /** * List actions supported in SmartServer. * @return * @throws IOException */ List<ActionDescriptor> listActionsSupported() throws IOException; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/SmartServerProtocols.java
smart-common/src/main/java/org/smartdata/protocol/SmartServerProtocols.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol; import org.apache.hadoop.security.KerberosInfo; import org.smartdata.conf.SmartConfKeys; @KerberosInfo( serverPrincipal = SmartConfKeys.SMART_SERVER_KERBEROS_PRINCIPAL_KEY) public interface SmartServerProtocols extends SmartClientProtocol, SmartAdminProtocol { }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/protobuffer/ProtoBufferHelper.java
smart-common/src/main/java/org/smartdata/protocol/protobuffer/ProtoBufferHelper.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.protobuffer; import com.google.protobuf.ServiceException; import org.smartdata.metrics.FileAccessEvent; import org.smartdata.model.ActionDescriptor; import org.smartdata.model.ActionInfo; import org.smartdata.model.CmdletDescriptor; import org.smartdata.model.CmdletInfo; import org.smartdata.model.CmdletState; import org.smartdata.model.CompactFileState; import org.smartdata.model.CompressionFileState; import org.smartdata.model.FileContainerInfo; import org.smartdata.model.FileState; import org.smartdata.model.NormalFileState; import org.smartdata.model.RuleInfo; import org.smartdata.model.RuleState; import org.smartdata.protocol.AdminServerProto.ActionDescriptorProto; import org.smartdata.protocol.AdminServerProto.ActionInfoProto; import org.smartdata.protocol.AdminServerProto.ActionInfoProto.Builder; import org.smartdata.protocol.AdminServerProto.CmdletInfoProto; import org.smartdata.protocol.AdminServerProto.RuleInfoProto; import org.smartdata.protocol.ClientServerProto.CompactFileStateProto; import org.smartdata.protocol.ClientServerProto.CompressionFileStateProto; import org.smartdata.protocol.ClientServerProto.FileStateProto; import org.smartdata.protocol.ClientServerProto.ReportFileAccessEventRequestProto; import org.smartdata.protocol.ClientServerProto.S3FileStateProto; import java.io.IOException; import java.text.ParseException; import java.util.Arrays; import java.util.List; public class ProtoBufferHelper { private ProtoBufferHelper() { } public static IOException getRemoteException(ServiceException se) { Throwable e = se.getCause(); if (e == null) { return new IOException(se); } return e instanceof IOException ? (IOException) e : new IOException(se); } public static int convert(RuleState state) { return state.getValue(); } public static RuleState convert(int state) { return RuleState.fromValue(state); } public static RuleInfoProto convert(RuleInfo info) { return RuleInfoProto.newBuilder().setId(info.getId()) .setSubmitTime(info.getSubmitTime()) .setLastCheckTime(info.getLastCheckTime()) .setRuleText(info.getRuleText()) .setNumChecked(info.getNumChecked()) .setNumCmdsGen(info.getNumCmdsGen()) .setRulestateProto(convert(info.getState())).build(); } public static RuleInfo convert(RuleInfoProto proto) { return RuleInfo.newBuilder().setId(proto.getId()) .setSubmitTime(proto.getSubmitTime()) .setLastCheckTime(proto.getLastCheckTime()) .setRuleText(proto.getRuleText()) .setNumChecked(proto.getNumChecked()) .setNumCmdsGen(proto.getNumCmdsGen()) .setState(convert(proto.getRulestateProto())).build(); } public static CmdletInfo convert(CmdletInfoProto proto) { // TODO replace actionType with aids CmdletInfo.Builder builder = CmdletInfo.newBuilder(); builder.setCid(proto.getCid()) .setRid(proto.getRid()) .setState(CmdletState.fromValue(proto.getState())) .setParameters(proto.getParameters()) .setGenerateTime(proto.getGenerateTime()) .setStateChangedTime(proto.getStateChangedTime()); List<Long> list = proto.getAidsList(); builder.setAids(list); return builder.build(); } public static CmdletInfoProto convert(CmdletInfo info) { // TODO replace actionType with aids CmdletInfoProto.Builder builder = CmdletInfoProto.newBuilder(); builder.setCid(info.getCid()) .setRid(info.getRid()) .setState(info.getState().getValue()) .setParameters(info.getParameters()) .setGenerateTime(info.getGenerateTime()) .setStateChangedTime(info.getStateChangedTime()); builder.addAllAids(info.getAids()); return builder.build(); } public static ReportFileAccessEventRequestProto convert(FileAccessEvent event) { return ReportFileAccessEventRequestProto.newBuilder() .setFilePath(event.getPath()) .setAccessedBy(event.getAccessedBy()) .setFileId(event.getFileId()) .build(); } public static ActionInfoProto convert(ActionInfo actionInfo) { Builder builder = ActionInfoProto.newBuilder(); builder.setActionName(actionInfo.getActionName()) .setResult(actionInfo.getResult()) .setLog(actionInfo.getLog()) .setSuccessful(actionInfo.isSuccessful()) .setCreateTime(actionInfo.getCreateTime()) .setFinished(actionInfo.isFinished()) .setFinishTime(actionInfo.getFinishTime()) .setProgress(actionInfo.getProgress()) .setActionId(actionInfo.getActionId()) .setCmdletId(actionInfo.getCmdletId()); builder.addAllArgs(CmdletDescriptor.toArgList(actionInfo.getArgs())); return builder.build(); } public static ActionInfo convert(ActionInfoProto infoProto) { ActionInfo.Builder builder = ActionInfo.newBuilder(); builder.setActionName(infoProto.getActionName()) .setResult(infoProto.getResult()) .setLog(infoProto.getLog()) .setSuccessful(infoProto.getSuccessful()) .setCreateTime(infoProto.getCreateTime()) .setFinished(infoProto.getFinished()) .setFinishTime(infoProto.getFinishTime()) .setProgress(infoProto.getProgress()) .setActionId(infoProto.getActionId()) .setCmdletId(infoProto.getCmdletId()); List<String> list = infoProto.getArgsList(); try { builder.setArgs(CmdletDescriptor.toArgMap(list)); } catch (ParseException e) { return null; } return builder.build(); } public static FileAccessEvent convert(final ReportFileAccessEventRequestProto event) { return new FileAccessEvent(event.getFilePath(), 0, event.getAccessedBy()); } public static ActionDescriptor convert(ActionDescriptorProto proto) { return ActionDescriptor.newBuilder() .setActionName(proto.getActionName()) .setComment(proto.getComment()) .setDisplayName(proto.getDisplayName()) .setUsage(proto.getUsage()) .build(); } public static ActionDescriptorProto convert(ActionDescriptor ac) { return ActionDescriptorProto.newBuilder() .setActionName(ac.getActionName()) .setComment(ac.getComment()) .setDisplayName(ac.getDisplayName()) .setUsage(ac.getUsage()) .build(); } private static FileContainerInfo convert(CompactFileStateProto proto) { String containerFilePath = proto.getContainerFilePath(); long offset = proto.getOffset(); long length = proto.getLength(); return new FileContainerInfo(containerFilePath, offset, length); } public static FileState convert(FileStateProto proto) { FileState fileState = null; String path = proto.getPath(); FileState.FileType type = FileState.FileType.fromValue(proto.getType()); FileState.FileStage stage = FileState.FileStage.fromValue(proto.getStage()); /// Unusable temporarily // FileState.FileStage stage = FileState.FileStage.fromValue(proto.getStage()); if (type == null) { return new NormalFileState(path); } switch (type) { case NORMAL: fileState = new NormalFileState(path); break; case COMPACT: CompactFileStateProto compactProto = proto.getCompactFileState(); fileState = new CompactFileState(path, convert(compactProto)); break; case COMPRESSION: CompressionFileStateProto compressionProto = proto.getCompressionFileState(); // convert to CompressionFileState fileState = convert(path, stage, compressionProto); break; case S3: S3FileStateProto s3Proto = proto.getS3FileState(); // convert to S3FileState // fileState = convert(path, type, stage, s3Proto); break; default: } return fileState; } public static FileStateProto convert(FileState fileState) { FileStateProto.Builder builder = FileStateProto.newBuilder(); builder.setPath(fileState.getPath()) .setType(fileState.getFileType().getValue()) .setStage(fileState.getFileStage().getValue()); if (fileState instanceof CompactFileState) { FileContainerInfo fileContainerInfo = ( (CompactFileState) fileState).getFileContainerInfo(); builder.setCompactFileState(CompactFileStateProto.newBuilder() .setContainerFilePath(fileContainerInfo.getContainerFilePath()) .setOffset(fileContainerInfo.getOffset()) .setLength(fileContainerInfo.getLength())); } else if (fileState instanceof CompressionFileState) { builder.setCompressionFileState(convert((CompressionFileState) fileState)); } /*else if (fileState instanceof S3FileState) { builder.setS3FileState(); } else if (fileState instanceof ) { } */ return builder.build(); } public static CompressionFileState convert(String path, FileState.FileStage stage, CompressionFileStateProto proto) { CompressionFileState.Builder builder = CompressionFileState.newBuilder(); builder.setFileName(path) .setFileStage(stage) .setBufferSize(proto.getBufferSize()) .setCompressImpl(proto.getCompressionImpl()) .setOriginalLength(proto.getOriginalLength()) .setCompressedLength(proto.getCompressedLength()) .setOriginalPos(proto.getOriginalPosList()) .setCompressedPos(proto.getCompressedPosList()); return builder.build(); } public static CompressionFileStateProto convert(CompressionFileState fileState) { CompressionFileStateProto.Builder builder = CompressionFileStateProto.newBuilder(); builder.setBufferSize(fileState.getBufferSize()) .setCompressionImpl(fileState.getCompressionImpl()) .setOriginalLength(fileState.getOriginalLength()) .setCompressedLength(fileState.getCompressedLength()); builder.addAllOriginalPos(Arrays.asList(fileState.getOriginalPos())); builder.addAllCompressedPos(Arrays.asList(fileState.getCompressedPos())); return builder.build(); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/protobuffer/ServerProtocolsProtoBuffer.java
smart-common/src/main/java/org/smartdata/protocol/protobuffer/ServerProtocolsProtoBuffer.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.protobuffer; public interface ServerProtocolsProtoBuffer extends ClientProtocolProtoBuffer, AdminProtocolProtoBuffer { }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/protobuffer/ServerProtocolsServerSideTranslator.java
smart-common/src/main/java/org/smartdata/protocol/protobuffer/ServerProtocolsServerSideTranslator.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.protobuffer; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; import org.smartdata.SmartServiceState; import org.smartdata.model.ActionDescriptor; import org.smartdata.model.ActionInfo; import org.smartdata.model.CmdletInfo; import org.smartdata.model.CmdletState; import org.smartdata.model.FileState; import org.smartdata.model.RuleInfo; import org.smartdata.protocol.AdminServerProto; import org.smartdata.protocol.AdminServerProto.ActionDescriptorProto; import org.smartdata.protocol.AdminServerProto.ActionInfoProto; import org.smartdata.protocol.AdminServerProto.ActivateCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.ActivateCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.ActivateRuleRequestProto; import org.smartdata.protocol.AdminServerProto.ActivateRuleResponseProto; import org.smartdata.protocol.AdminServerProto.CheckRuleRequestProto; import org.smartdata.protocol.AdminServerProto.CheckRuleResponseProto; import org.smartdata.protocol.AdminServerProto.CmdletInfoProto; import org.smartdata.protocol.AdminServerProto.DeleteCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.DeleteCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.DeleteRuleRequestProto; import org.smartdata.protocol.AdminServerProto.DeleteRuleResponseProto; import org.smartdata.protocol.AdminServerProto.DisableCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.DisableCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.DisableRuleRequestProto; import org.smartdata.protocol.AdminServerProto.DisableRuleResponseProto; import org.smartdata.protocol.AdminServerProto.GetActionInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetActionInfoResponseProto; import org.smartdata.protocol.AdminServerProto.GetCmdletInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetCmdletInfoResponseProto; import org.smartdata.protocol.AdminServerProto.GetRuleInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetRuleInfoResponseProto; import org.smartdata.protocol.AdminServerProto.GetServiceStateRequestProto; import org.smartdata.protocol.AdminServerProto.GetServiceStateResponseProto; import org.smartdata.protocol.AdminServerProto.ListActionInfoOfLastActionsRequestProto; import org.smartdata.protocol.AdminServerProto.ListActionInfoOfLastActionsResponseProto; import org.smartdata.protocol.AdminServerProto.ListActionsSupportedRequestProto; import org.smartdata.protocol.AdminServerProto.ListActionsSupportedResponseProto; import org.smartdata.protocol.AdminServerProto.ListCmdletInfoRequestProto; import org.smartdata.protocol.AdminServerProto.ListCmdletInfoResponseProto; import org.smartdata.protocol.AdminServerProto.ListRulesInfoRequestProto; import org.smartdata.protocol.AdminServerProto.ListRulesInfoResponseProto; import org.smartdata.protocol.AdminServerProto.RuleInfoProto; import org.smartdata.protocol.AdminServerProto.SubmitCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.SubmitCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.SubmitRuleRequestProto; import org.smartdata.protocol.AdminServerProto.SubmitRuleResponseProto; import org.smartdata.protocol.ClientServerProto; import org.smartdata.protocol.ClientServerProto.GetFileStateRequestProto; import org.smartdata.protocol.ClientServerProto.GetFileStateResponseProto; import org.smartdata.protocol.ClientServerProto.ReportFileAccessEventRequestProto; import org.smartdata.protocol.ClientServerProto.ReportFileAccessEventResponseProto; import org.smartdata.protocol.SmartServerProtocols; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class ServerProtocolsServerSideTranslator implements ServerProtocolsProtoBuffer, AdminServerProto.protoService.BlockingInterface, ClientServerProto.protoService.BlockingInterface { private final SmartServerProtocols server; public ServerProtocolsServerSideTranslator(SmartServerProtocols server) { this.server = server; } @Override public GetServiceStateResponseProto getServiceState(RpcController controller, GetServiceStateRequestProto req) throws ServiceException { SmartServiceState s = null; try { s = server.getServiceState(); } catch (IOException e) { throw new ServiceException(e); } return GetServiceStateResponseProto.newBuilder() .setState(s.getValue()).build(); } @Override public SubmitRuleResponseProto submitRule(RpcController controller, SubmitRuleRequestProto req) throws ServiceException { try { long ruleId = server.submitRule(req.getRule(), ProtoBufferHelper.convert(req.getInitState())); return SubmitRuleResponseProto.newBuilder().setRuleId(ruleId).build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public CheckRuleResponseProto checkRule(RpcController controller, CheckRuleRequestProto req) throws ServiceException { try { server.checkRule(req.getRule()); return CheckRuleResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetRuleInfoResponseProto getRuleInfo(RpcController controller, GetRuleInfoRequestProto req) throws ServiceException { try { RuleInfo info = server.getRuleInfo(req.getRuleId()); return GetRuleInfoResponseProto.newBuilder() .setResult(ProtoBufferHelper.convert(info)).build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public ListRulesInfoResponseProto listRulesInfo(RpcController controller, ListRulesInfoRequestProto req) throws ServiceException { try { List<RuleInfo> infos = server.listRulesInfo(); List<RuleInfoProto> infoProtos = new ArrayList<>(); for (RuleInfo info : infos) { infoProtos.add(ProtoBufferHelper.convert(info)); } return ListRulesInfoResponseProto.newBuilder() .addAllRulesInfo(infoProtos).build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public DeleteRuleResponseProto deleteRule(RpcController controller, DeleteRuleRequestProto req) throws ServiceException { try { server.deleteRule(req.getRuleId(), req.getDropPendingCmdlets()); return DeleteRuleResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public ActivateRuleResponseProto activateRule(RpcController controller, ActivateRuleRequestProto req) throws ServiceException { try { server.activateRule(req.getRuleId()); return ActivateRuleResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public DisableRuleResponseProto disableRule(RpcController controller, DisableRuleRequestProto req) throws ServiceException { try { server.disableRule(req.getRuleId(), req.getDropPendingCmdlets()); return DisableRuleResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetCmdletInfoResponseProto getCmdletInfo( RpcController controller, GetCmdletInfoRequestProto req) throws ServiceException { try { CmdletInfo cmdletInfo = server.getCmdletInfo(req.getCmdletID()); return GetCmdletInfoResponseProto .newBuilder() .setCmdletInfo(ProtoBufferHelper.convert(cmdletInfo)) .build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public ListCmdletInfoResponseProto listCmdletInfo( RpcController controller, ListCmdletInfoRequestProto req) throws ServiceException { try { List<CmdletInfo> list = server.listCmdletInfo(req.getRuleID(), CmdletState.fromValue(req.getCmdletState())); if (list == null) { return ListCmdletInfoResponseProto.newBuilder().build(); } List<CmdletInfoProto> protoList = new ArrayList<>(); for (CmdletInfo info : list) { protoList.add(ProtoBufferHelper.convert(info)); } return ListCmdletInfoResponseProto.newBuilder() .addAllCmdletInfos(protoList).build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public ActivateCmdletResponseProto activateCmdlet( RpcController controller, ActivateCmdletRequestProto req) throws ServiceException { try { server.activateCmdlet(req.getCmdletID()); return ActivateCmdletResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public DisableCmdletResponseProto disableCmdlet( RpcController controller, DisableCmdletRequestProto req) throws ServiceException { try { server.disableCmdlet(req.getCmdletID()); return DisableCmdletResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public DeleteCmdletResponseProto deleteCmdlet( RpcController controller, DeleteCmdletRequestProto req) throws ServiceException { try { server.deleteCmdlet(req.getCmdletID()); return DeleteCmdletResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetActionInfoResponseProto getActionInfo(RpcController controller, GetActionInfoRequestProto request) throws ServiceException { try { ActionInfo aI = server.getActionInfo(request.getActionID()); return GetActionInfoResponseProto.newBuilder() .setActionInfo(ProtoBufferHelper.convert(aI)).build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public ListActionInfoOfLastActionsResponseProto listActionInfoOfLastActions( RpcController controller, ListActionInfoOfLastActionsRequestProto request) throws ServiceException { try { List<ActionInfo> list = server.listActionInfoOfLastActions(request.getMaxNumActions()); if (list == null) { return ListActionInfoOfLastActionsResponseProto.newBuilder().build(); } List<ActionInfoProto> protoList = new ArrayList<>(); for (ActionInfo a:list){ protoList.add(ProtoBufferHelper.convert(a)); } return ListActionInfoOfLastActionsResponseProto.newBuilder() .addAllActionInfoList(protoList).build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public SubmitCmdletResponseProto submitCmdlet(RpcController controller, SubmitCmdletRequestProto req) throws ServiceException { try { long id = server.submitCmdlet(req.getCmd()); return SubmitCmdletResponseProto.newBuilder() .setRes(id).build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public ListActionsSupportedResponseProto listActionsSupported( RpcController controller, ListActionsSupportedRequestProto req) throws ServiceException { try { List<ActionDescriptor> adList = server.listActionsSupported(); List<ActionDescriptorProto> prolist = new ArrayList<>(); for (ActionDescriptor a : adList) { prolist.add(ProtoBufferHelper.convert(a)); } return ListActionsSupportedResponseProto.newBuilder() .addAllActDesList(prolist) .build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public ReportFileAccessEventResponseProto reportFileAccessEvent( RpcController controller, ReportFileAccessEventRequestProto req) throws ServiceException { try { server.reportFileAccessEvent(ProtoBufferHelper.convert(req)); return ReportFileAccessEventResponseProto.newBuilder().build(); } catch (IOException e) { throw new ServiceException(e); } } @Override public GetFileStateResponseProto getFileState(RpcController controller, GetFileStateRequestProto req) throws ServiceException { try { String path = req.getFilePath(); FileState fileState = server.getFileState(path); return GetFileStateResponseProto.newBuilder() .setFileState(ProtoBufferHelper.convert(fileState)) .build(); } catch (IOException e) { throw new ServiceException(e); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/protobuffer/ClientProtocolProtoBuffer.java
smart-common/src/main/java/org/smartdata/protocol/protobuffer/ClientProtocolProtoBuffer.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.protobuffer; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; import org.apache.hadoop.ipc.ProtocolInfo; import org.apache.hadoop.security.KerberosInfo; import org.smartdata.SmartConstants; import org.smartdata.conf.SmartConfKeys; import org.smartdata.protocol.ClientServerProto.GetFileStateRequestProto; import org.smartdata.protocol.ClientServerProto.GetFileStateResponseProto; import org.smartdata.protocol.ClientServerProto.ReportFileAccessEventRequestProto; import org.smartdata.protocol.ClientServerProto.ReportFileAccessEventResponseProto; @KerberosInfo( serverPrincipal = SmartConfKeys.SMART_SERVER_KERBEROS_PRINCIPAL_KEY) @ProtocolInfo(protocolName = SmartConstants.SMART_CLIENT_PROTOCOL_NAME, protocolVersion = 1) public interface ClientProtocolProtoBuffer { ReportFileAccessEventResponseProto reportFileAccessEvent(RpcController controller, ReportFileAccessEventRequestProto req) throws ServiceException; GetFileStateResponseProto getFileState(RpcController controller, GetFileStateRequestProto req) throws ServiceException; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/protobuffer/ClientProtocolClientSideTranslator.java
smart-common/src/main/java/org/smartdata/protocol/protobuffer/ClientProtocolClientSideTranslator.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.protobuffer; import com.google.protobuf.ServiceException; import org.apache.hadoop.ipc.RPC; import org.smartdata.metrics.FileAccessEvent; import org.smartdata.model.FileState; import org.smartdata.protocol.ClientServerProto.GetFileStateRequestProto; import org.smartdata.protocol.ClientServerProto.GetFileStateResponseProto; import org.smartdata.protocol.ClientServerProto.ReportFileAccessEventRequestProto; import org.smartdata.protocol.SmartClientProtocol; import java.io.IOException; public class ClientProtocolClientSideTranslator implements java.io.Closeable, SmartClientProtocol { private ClientProtocolProtoBuffer rpcProxy; public ClientProtocolClientSideTranslator( ClientProtocolProtoBuffer proxy) { rpcProxy = proxy; } @Override public void close() throws IOException { RPC.stopProxy(rpcProxy); rpcProxy = null; } @Override public void reportFileAccessEvent(FileAccessEvent event) throws IOException { ReportFileAccessEventRequestProto req = ReportFileAccessEventRequestProto.newBuilder() .setFilePath(event.getPath()) .setFileId(0) .setAccessedBy(event.getAccessedBy()) .build(); try { rpcProxy.reportFileAccessEvent(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public FileState getFileState(String filePath) throws IOException { GetFileStateRequestProto req = GetFileStateRequestProto.newBuilder() .setFilePath(filePath) .build(); try { GetFileStateResponseProto response = rpcProxy.getFileState(null, req); return ProtoBufferHelper.convert(response.getFileState()); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/protobuffer/AdminProtocolProtoBuffer.java
smart-common/src/main/java/org/smartdata/protocol/protobuffer/AdminProtocolProtoBuffer.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.protobuffer; import com.google.protobuf.RpcController; import com.google.protobuf.ServiceException; import org.apache.hadoop.ipc.ProtocolInfo; import org.apache.hadoop.security.KerberosInfo; import org.smartdata.SmartConstants; import org.smartdata.conf.SmartConfKeys; import org.smartdata.protocol.AdminServerProto.ActivateCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.ActivateCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.ActivateRuleRequestProto; import org.smartdata.protocol.AdminServerProto.ActivateRuleResponseProto; import org.smartdata.protocol.AdminServerProto.CheckRuleRequestProto; import org.smartdata.protocol.AdminServerProto.CheckRuleResponseProto; import org.smartdata.protocol.AdminServerProto.DeleteCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.DeleteCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.DeleteRuleRequestProto; import org.smartdata.protocol.AdminServerProto.DeleteRuleResponseProto; import org.smartdata.protocol.AdminServerProto.DisableCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.DisableCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.DisableRuleRequestProto; import org.smartdata.protocol.AdminServerProto.DisableRuleResponseProto; import org.smartdata.protocol.AdminServerProto.GetActionInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetActionInfoResponseProto; import org.smartdata.protocol.AdminServerProto.GetCmdletInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetCmdletInfoResponseProto; import org.smartdata.protocol.AdminServerProto.GetRuleInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetRuleInfoResponseProto; import org.smartdata.protocol.AdminServerProto.GetServiceStateRequestProto; import org.smartdata.protocol.AdminServerProto.GetServiceStateResponseProto; import org.smartdata.protocol.AdminServerProto.ListActionInfoOfLastActionsRequestProto; import org.smartdata.protocol.AdminServerProto.ListActionInfoOfLastActionsResponseProto; import org.smartdata.protocol.AdminServerProto.ListActionsSupportedRequestProto; import org.smartdata.protocol.AdminServerProto.ListActionsSupportedResponseProto; import org.smartdata.protocol.AdminServerProto.ListCmdletInfoRequestProto; import org.smartdata.protocol.AdminServerProto.ListCmdletInfoResponseProto; import org.smartdata.protocol.AdminServerProto.ListRulesInfoRequestProto; import org.smartdata.protocol.AdminServerProto.ListRulesInfoResponseProto; import org.smartdata.protocol.AdminServerProto.SubmitCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.SubmitCmdletResponseProto; import org.smartdata.protocol.AdminServerProto.SubmitRuleRequestProto; import org.smartdata.protocol.AdminServerProto.SubmitRuleResponseProto; @KerberosInfo( serverPrincipal = SmartConfKeys.SMART_SERVER_KERBEROS_PRINCIPAL_KEY) @ProtocolInfo(protocolName = SmartConstants.SMART_ADMIN_PROTOCOL_NAME, protocolVersion = 1) public interface AdminProtocolProtoBuffer { GetServiceStateResponseProto getServiceState(RpcController controller, GetServiceStateRequestProto req) throws ServiceException; GetRuleInfoResponseProto getRuleInfo(RpcController controller, GetRuleInfoRequestProto req) throws ServiceException; SubmitRuleResponseProto submitRule(RpcController controller, SubmitRuleRequestProto req) throws ServiceException; CheckRuleResponseProto checkRule(RpcController controller, CheckRuleRequestProto req) throws ServiceException; ListRulesInfoResponseProto listRulesInfo(RpcController controller, ListRulesInfoRequestProto req) throws ServiceException; DeleteRuleResponseProto deleteRule(RpcController controller, DeleteRuleRequestProto req) throws ServiceException; ActivateRuleResponseProto activateRule(RpcController controller, ActivateRuleRequestProto req) throws ServiceException; DisableRuleResponseProto disableRule(RpcController controller, DisableRuleRequestProto req) throws ServiceException; GetCmdletInfoResponseProto getCmdletInfo(RpcController controller, GetCmdletInfoRequestProto req) throws ServiceException; ListCmdletInfoResponseProto listCmdletInfo(RpcController controller, ListCmdletInfoRequestProto req) throws ServiceException; ActivateCmdletResponseProto activateCmdlet(RpcController controller, ActivateCmdletRequestProto req) throws ServiceException; DisableCmdletResponseProto disableCmdlet(RpcController controller, DisableCmdletRequestProto req) throws ServiceException; DeleteCmdletResponseProto deleteCmdlet(RpcController controller, DeleteCmdletRequestProto req) throws ServiceException; GetActionInfoResponseProto getActionInfo(RpcController controller, GetActionInfoRequestProto req) throws ServiceException; ListActionInfoOfLastActionsResponseProto listActionInfoOfLastActions( RpcController controller, ListActionInfoOfLastActionsRequestProto req) throws ServiceException; SubmitCmdletResponseProto submitCmdlet( RpcController controller, SubmitCmdletRequestProto req) throws ServiceException; ListActionsSupportedResponseProto listActionsSupported( RpcController controller, ListActionsSupportedRequestProto req) throws ServiceException; }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/protobuffer/AdminProtocolClientSideTranslator.java
smart-common/src/main/java/org/smartdata/protocol/protobuffer/AdminProtocolClientSideTranslator.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.protobuffer; import com.google.protobuf.ServiceException; import org.apache.hadoop.ipc.RPC; import org.smartdata.SmartServiceState; import org.smartdata.model.ActionDescriptor; import org.smartdata.model.ActionInfo; import org.smartdata.model.CmdletInfo; import org.smartdata.model.CmdletState; import org.smartdata.model.RuleInfo; import org.smartdata.model.RuleState; import org.smartdata.protocol.AdminServerProto.ActionDescriptorProto; import org.smartdata.protocol.AdminServerProto.ActionInfoProto; import org.smartdata.protocol.AdminServerProto.ActivateCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.ActivateRuleRequestProto; import org.smartdata.protocol.AdminServerProto.CheckRuleRequestProto; import org.smartdata.protocol.AdminServerProto.CmdletInfoProto; import org.smartdata.protocol.AdminServerProto.DeleteCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.DeleteRuleRequestProto; import org.smartdata.protocol.AdminServerProto.DisableCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.DisableRuleRequestProto; import org.smartdata.protocol.AdminServerProto.GetActionInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetCmdletInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetRuleInfoRequestProto; import org.smartdata.protocol.AdminServerProto.GetRuleInfoResponseProto; import org.smartdata.protocol.AdminServerProto.GetServiceStateRequestProto; import org.smartdata.protocol.AdminServerProto.ListActionInfoOfLastActionsRequestProto; import org.smartdata.protocol.AdminServerProto.ListActionsSupportedRequestProto; import org.smartdata.protocol.AdminServerProto.ListCmdletInfoRequestProto; import org.smartdata.protocol.AdminServerProto.ListRulesInfoRequestProto; import org.smartdata.protocol.AdminServerProto.RuleInfoProto; import org.smartdata.protocol.AdminServerProto.SubmitCmdletRequestProto; import org.smartdata.protocol.AdminServerProto.SubmitRuleRequestProto; import org.smartdata.protocol.SmartAdminProtocol; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class AdminProtocolClientSideTranslator implements java.io.Closeable, SmartAdminProtocol { private AdminProtocolProtoBuffer rpcProxy; public AdminProtocolClientSideTranslator(AdminProtocolProtoBuffer proxy) { this.rpcProxy = proxy; } @Override public SmartServiceState getServiceState() throws IOException { GetServiceStateRequestProto req = GetServiceStateRequestProto.newBuilder().build(); try { return SmartServiceState.fromValue( rpcProxy.getServiceState(null, req).getState()); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public RuleInfo getRuleInfo(long id) throws IOException { try { GetRuleInfoRequestProto req = GetRuleInfoRequestProto.newBuilder().setRuleId(id).build(); GetRuleInfoResponseProto r = rpcProxy.getRuleInfo(null, req); return ProtoBufferHelper.convert(r.getResult()); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public long submitRule(String rule, RuleState initState) throws IOException { try { SubmitRuleRequestProto req = SubmitRuleRequestProto.newBuilder() .setRule(rule).setInitState(ProtoBufferHelper.convert(initState)).build(); return rpcProxy.submitRule(null, req).getRuleId(); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public void checkRule(String rule) throws IOException { try { CheckRuleRequestProto req = CheckRuleRequestProto.newBuilder() .setRule(rule).build(); rpcProxy.checkRule(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public List<RuleInfo> listRulesInfo() throws IOException { try { ListRulesInfoRequestProto req = ListRulesInfoRequestProto.newBuilder() .build(); List<RuleInfoProto> infoProtos = rpcProxy.listRulesInfo(null, req).getRulesInfoList(); if (infoProtos == null) { return null; } List<RuleInfo> ret = new ArrayList<>(); for (RuleInfoProto infoProto : infoProtos) { ret.add(ProtoBufferHelper.convert(infoProto)); } return ret; } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public void deleteRule(long ruleID, boolean dropPendingCmdlets) throws IOException { DeleteRuleRequestProto req = DeleteRuleRequestProto.newBuilder() .setRuleId(ruleID) .setDropPendingCmdlets(dropPendingCmdlets) .build(); try { rpcProxy.deleteRule(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public void activateRule(long ruleID) throws IOException { ActivateRuleRequestProto req = ActivateRuleRequestProto.newBuilder() .setRuleId(ruleID).build(); try { rpcProxy.activateRule(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public void disableRule(long ruleID, boolean dropPendingCmdlets) throws IOException { DisableRuleRequestProto req = DisableRuleRequestProto.newBuilder() .setRuleId(ruleID) .setDropPendingCmdlets(dropPendingCmdlets) .build(); try { rpcProxy.disableRule(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } // TODO Cmdlet RPC Client Interface @Override public CmdletInfo getCmdletInfo(long cmdletID) throws IOException { GetCmdletInfoRequestProto req = GetCmdletInfoRequestProto.newBuilder() .setCmdletID(cmdletID).build(); try { return ProtoBufferHelper.convert(rpcProxy.getCmdletInfo(null, req).getCmdletInfo()); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public List<CmdletInfo> listCmdletInfo(long rid, CmdletState cmdletState) throws IOException { ListCmdletInfoRequestProto req = ListCmdletInfoRequestProto.newBuilder() .setRuleID(rid).setCmdletState(cmdletState.getValue()) .build(); try { List<CmdletInfoProto> protoslist = rpcProxy.listCmdletInfo(null, req).getCmdletInfosList(); if (protoslist == null) { return new ArrayList<>(); } List<CmdletInfo> list = new ArrayList<>(); for (CmdletInfoProto infoProto : protoslist) { list.add(ProtoBufferHelper.convert(infoProto)); } return list; } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public void activateCmdlet(long cmdletID) throws IOException { try { ActivateCmdletRequestProto req = ActivateCmdletRequestProto.newBuilder() .setCmdletID(cmdletID) .build(); rpcProxy.activateCmdlet(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public void disableCmdlet(long cmdletID) throws IOException { try { DisableCmdletRequestProto req = DisableCmdletRequestProto.newBuilder() .setCmdletID(cmdletID) .build(); rpcProxy.disableCmdlet(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public void deleteCmdlet(long cmdletID) throws IOException { try { DeleteCmdletRequestProto req = DeleteCmdletRequestProto.newBuilder() .setCmdletID(cmdletID) .build(); rpcProxy.deleteCmdlet(null, req); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public ActionInfo getActionInfo(long actionID) throws IOException { GetActionInfoRequestProto req = GetActionInfoRequestProto.newBuilder() .setActionID(actionID) .build(); try { return ProtoBufferHelper.convert(rpcProxy.getActionInfo(null, req).getActionInfo()); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public List<ActionInfo> listActionInfoOfLastActions(int maxNumActions) throws IOException { ListActionInfoOfLastActionsRequestProto req = ListActionInfoOfLastActionsRequestProto.newBuilder() .setMaxNumActions(maxNumActions).build(); try { List<ActionInfoProto> protoslist = rpcProxy.listActionInfoOfLastActions(null, req).getActionInfoListList(); if (protoslist == null) { return new ArrayList<>(); } List<ActionInfo> list = new ArrayList<>(); for (ActionInfoProto infoProto : protoslist) { list.add(ProtoBufferHelper.convert(infoProto)); } return list; } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public long submitCmdlet(String cmd) throws IOException { SubmitCmdletRequestProto req = SubmitCmdletRequestProto.newBuilder() .setCmd(cmd).build(); try { return rpcProxy.submitCmdlet(null, req).getRes(); } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } @Override public List<ActionDescriptor> listActionsSupported() throws IOException { ListActionsSupportedRequestProto req = ListActionsSupportedRequestProto .newBuilder().build(); try { List<ActionDescriptorProto> prolist = rpcProxy .listActionsSupported(null, req).getActDesListList(); List<ActionDescriptor> list = new ArrayList<>(); for (ActionDescriptorProto a : prolist){ list.add(ProtoBufferHelper.convert(a)); } return list; } catch (ServiceException e) { throw ProtoBufferHelper.getRemoteException(e); } } /** * Closes this stream and releases any system resources associated * with it. If the stream is already closed then invoking this * method has no effect. * * <p>As noted in {@link AutoCloseable#close()}, cases where the * close may fail require careful attention. It is strongly advised * to relinquish the underlying resources and to internally * <em>mark</em> the {@code Closeable} as closed, prior to throwing * the {@code IOException}. * * @throws IOException if an I/O error occurs */ @Override public void close() throws IOException { RPC.stopProxy(rpcProxy); rpcProxy = null; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/CmdletStatusUpdate.java
smart-common/src/main/java/org/smartdata/protocol/message/CmdletStatusUpdate.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import org.smartdata.model.CmdletState; public class CmdletStatusUpdate implements StatusMessage { private long cmdletId; private long timestamp; private CmdletState currentState; public CmdletStatusUpdate(long cmdletId, long timestamp, CmdletState currentState) { this.cmdletId = cmdletId; this.timestamp = timestamp; this.currentState = currentState; } public CmdletStatus getCmdletStatus() { return new CmdletStatus(cmdletId, timestamp, currentState); } public long getCmdletId() { return cmdletId; } public void setCmdletId(long cmdletId) { this.cmdletId = cmdletId; } public long getTimestamp() { return timestamp; } public void setTimestamp(long timestamp) { this.timestamp = timestamp; } public CmdletState getCurrentState() { return currentState; } public void setCurrentState(CmdletState currentState) { this.currentState = currentState; } @Override public String toString() { return String.format("Cmdlet %s transfers to status %s", cmdletId, currentState); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/StatusReporter.java
smart-common/src/main/java/org/smartdata/protocol/message/StatusReporter.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; public interface StatusReporter { void report(StatusMessage status); }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/StatusReport.java
smart-common/src/main/java/org/smartdata/protocol/message/StatusReport.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import java.util.List; public class StatusReport implements StatusMessage { private List<ActionStatus> actionStatuses; public StatusReport(List<ActionStatus> actionStatuses) { this.actionStatuses = actionStatuses; } public List<ActionStatus> getActionStatuses() { return actionStatuses; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/StatusMessage.java
smart-common/src/main/java/org/smartdata/protocol/message/StatusMessage.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import java.io.Serializable; public interface StatusMessage extends Serializable { }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/ActionStatus.java
smart-common/src/main/java/org/smartdata/protocol/message/ActionStatus.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import java.io.Serializable; public class ActionStatus implements Serializable { private long cmdletId; private boolean lastAction; private long actionId; private float percentage; private String result; private String log; private long startTime; private long finishTime; private Throwable throwable; private boolean finished; public ActionStatus(long cmdletId, boolean lastAction, long actionId, float percentage, String result, String log, long startTime, long finishTime, Throwable t, boolean finished) { this.cmdletId = cmdletId; this.lastAction = lastAction; this.actionId = actionId; this.percentage = percentage; this.result = result; this.log = log; this.startTime = startTime; this.finishTime = finishTime; this.throwable = t; this.finished = finished; } public ActionStatus(long cmdletId, boolean lastAction, long actionId, String log, long startTime, long finishTime, Throwable t, boolean finished) { this.cmdletId = cmdletId; this.lastAction = lastAction; this.actionId = actionId; this.log = log; this.startTime = startTime; this.finishTime = finishTime; this.throwable = t; this.finished = finished; } public ActionStatus(long cmdletId, boolean lastAction, long actionId, String log, long startTime, long finishTime, Throwable t, boolean finished, String result) { this(cmdletId, lastAction, actionId, log, startTime, finishTime, t, finished); this.result = result; } public ActionStatus(long cmdletId, boolean lastAction, long actionId, long finishTime) { this.cmdletId = cmdletId; this.lastAction = lastAction; this.actionId = actionId; this.finishTime = finishTime; } public ActionStatus(long cmdletId, boolean lastAction, long actionId, long startTime, Throwable t) { this.cmdletId = cmdletId; this.lastAction = lastAction; this.actionId = actionId; this.startTime = startTime; this.throwable = t; } public long getCmdletId() { return cmdletId; } public void setCmdletId(long cmdletId) { this.cmdletId = cmdletId; } public boolean isLastAction() { return lastAction; } public void setLastAction(boolean lastAction) { this.lastAction = lastAction; } public long getActionId() { return actionId; } public void setActionId(long actionId) { this.actionId = actionId; } public float getPercentage() { return percentage; } public void setPercentage(float percentage) { this.percentage = percentage; } public String getResult() { if (result == null) { return ""; } return result; } public void setResult(String result) { this.result = result; } public String getLog() { if (log == null) { return ""; } return log; } public void setLog(String log) { this.log = log; } public long getStartTime() { return startTime; } public long getFinishTime() { return finishTime; } public Throwable getThrowable() { return throwable; } public boolean isFinished() { return finished; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/CmdletStatus.java
smart-common/src/main/java/org/smartdata/protocol/message/CmdletStatus.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import org.smartdata.model.CmdletState; import java.io.Serializable; public class CmdletStatus implements Serializable{ private long cmdletId; private long stateUpdateTime; private CmdletState currentState; public CmdletStatus(long cmdletId, long stateUpdateTime, CmdletState state) { this.cmdletId = cmdletId; this.stateUpdateTime = stateUpdateTime; this.currentState = state; } public long getCmdletId() { return cmdletId; } public long getStateUpdateTime() { return stateUpdateTime; } public CmdletState getCurrentState() { return currentState; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/LaunchCmdlet.java
smart-common/src/main/java/org/smartdata/protocol/message/LaunchCmdlet.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import org.smartdata.AgentService; import org.smartdata.SmartConstants; import org.smartdata.model.CmdletDispatchPolicy; import org.smartdata.model.LaunchAction; import java.util.List; /** * Command send out by Active SSM server to SSM Agents, Standby servers or itself for execution. * */ public class LaunchCmdlet implements AgentService.Message { private long cmdletId; private List<LaunchAction> launchActions; private CmdletDispatchPolicy dispPolicy = CmdletDispatchPolicy.ANY; private String nodeId; public LaunchCmdlet(long cmdletId, List<LaunchAction> launchActions) { this.cmdletId = cmdletId; this.launchActions = launchActions; } public long getCmdletId() { return cmdletId; } public void setCmdletId(long cmdletId) { this.cmdletId = cmdletId; } public List<LaunchAction> getLaunchActions() { return launchActions; } public void setLaunchActions(List<LaunchAction> launchActions) { this.launchActions = launchActions; } @Override public String getServiceName() { return SmartConstants.AGENT_CMDLET_SERVICE_NAME; } public CmdletDispatchPolicy getDispPolicy() { return dispPolicy; } public void setDispPolicy(CmdletDispatchPolicy dispPolicy) { this.dispPolicy = dispPolicy; } @Override public String toString() { return String.format("{cmdletId = %d, dispPolicy = '%s'}", cmdletId, dispPolicy); } public String getNodeId() { return nodeId; } public void setNodeId(String nodeId) { this.nodeId = nodeId; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/ActionStatusFactory.java
smart-common/src/main/java/org/smartdata/protocol/message/ActionStatusFactory.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import org.smartdata.model.ActionInfo; import org.smartdata.model.CmdletInfo; public class ActionStatusFactory { public static final String TIMEOUT_LOG = "Timeout error occurred for getting this action's status report."; public static final String ACTION_SKIP_LOG = "The action is not executed " + "because the prior action in the same cmdlet failed."; public static final String SUCCESS_BY_SPECULATION_LOG = "" + "The action was successfully executed according to speculation."; public static ActionStatus createSkipActionStatus(long cid, boolean isLastAction, long aid, long startTime, long finishTime) { return new ActionStatus(cid, isLastAction, aid, ACTION_SKIP_LOG, startTime, finishTime, new Throwable(), true); } /** * Create timeout action status. */ public static ActionStatus createTimeoutActionStatus( CmdletInfo cmdletInfo, ActionInfo actionInfo) { long cid = cmdletInfo.getCid(); long aid = actionInfo.getActionId(); long startTime = actionInfo.getCreateTime(); if (startTime == 0) { startTime = cmdletInfo.getGenerateTime(); } long finishTime = System.currentTimeMillis(); long lastAid = cmdletInfo.getAids().get(cmdletInfo.getAids().size() - 1); return new ActionStatus(cid, aid == lastAid, aid, TIMEOUT_LOG, startTime, finishTime, new Throwable(), true); } /** * Create successful action status by speculation. */ public static ActionStatus createSuccessActionStatus( CmdletInfo cmdletInfo, ActionInfo actionInfo) { long cid = cmdletInfo.getCid(); long aid = actionInfo.getActionId(); long startTime = actionInfo.getCreateTime(); if (startTime == 0) { startTime = cmdletInfo.getGenerateTime(); } long finishTime = System.currentTimeMillis(); long lastAid = cmdletInfo.getAids().get(cmdletInfo.getAids().size() - 1); // Action result can be set by scheduler. String result = actionInfo.getResult() != null ? actionInfo.getResult() : ""; return new ActionStatus(cid, aid == lastAid, aid, SUCCESS_BY_SPECULATION_LOG, startTime, finishTime, null, true, result); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-common/src/main/java/org/smartdata/protocol/message/StopCmdlet.java
smart-common/src/main/java/org/smartdata/protocol/message/StopCmdlet.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.protocol.message; import org.smartdata.AgentService; import org.smartdata.SmartConstants; public class StopCmdlet implements AgentService.Message { private long cmdletId; public StopCmdlet(long cmdletId) { this.cmdletId = cmdletId; } public long getCmdletId() { return cmdletId; } public void setCmdletId(long cmdletId) { this.cmdletId = cmdletId; } @Override public String getServiceName() { return SmartConstants.AGENT_CMDLET_SERVICE_NAME; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-agent/src/test/java/org.smartdata.agent/TestSmartAgent.java
smart-agent/src/test/java/org.smartdata.agent/TestSmartAgent.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.agent; import akka.actor.ActorSystem; import akka.testkit.JavaTestKit; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import org.junit.Test; import org.smartdata.conf.SmartConf; import org.smartdata.conf.SmartConfKeys; import org.smartdata.server.engine.cmdlet.agent.ActorSystemHarness; import org.smartdata.server.engine.cmdlet.agent.AgentConstants; import org.smartdata.server.engine.cmdlet.agent.AgentUtils; import org.smartdata.server.engine.cmdlet.agent.messages.AgentToMaster.RegisterNewAgent; import org.smartdata.server.engine.cmdlet.agent.messages.MasterToAgent; public class TestSmartAgent extends ActorSystemHarness { @Test public void testAgent() throws InterruptedException { ActorSystem system = getActorSystem(); final int num = 2; JavaTestKit[] masters = new JavaTestKit[num]; String[] masterPaths = new String[num]; for (int i = 0; i < num; i++) { masters[i] = new JavaTestKit(system); masterPaths[i] = AgentUtils.getFullPath(system, masters[i].getRef().path()); } SmartConf conf = new SmartConf(); AgentRunner runner = new AgentRunner( AgentUtils.overrideRemoteAddress(ConfigFactory.load(AgentConstants.AKKA_CONF_FILE), conf.get(SmartConfKeys.SMART_AGENT_ADDRESS_KEY)), masterPaths); runner.start(); masters[0].expectMsgClass(RegisterNewAgent.class); masters[0].reply(new MasterToAgent.AgentRegistered(new MasterToAgent.AgentId("test"))); system.stop(masters[0].getRef()); masters[1].expectMsgClass(RegisterNewAgent.class); } private class AgentRunner extends Thread { private final Config config; private final String[] masters; public AgentRunner(Config config, String[] masters) { this.config = config; this.masters = masters; } @Override public void run() { SmartAgent agent = new SmartAgent(); agent.start(config, masters, new SmartConf()); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-agent/src/main/java/org/smartdata/agent/SmartAgent.java
smart-agent/src/main/java/org/smartdata/agent/SmartAgent.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.agent; import akka.actor.ActorIdentity; import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.Cancellable; import akka.actor.Identify; import akka.actor.PoisonPill; import akka.actor.Props; import akka.actor.Terminated; import akka.actor.UntypedActor; import akka.japi.Procedure; import akka.pattern.Patterns; import akka.remote.AssociationEvent; import akka.remote.DisassociatedEvent; import akka.util.Timeout; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import org.apache.hadoop.security.UserGroupInformation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartdata.AgentService; import org.smartdata.SmartConstants; import org.smartdata.conf.SmartConf; import org.smartdata.conf.SmartConfKeys; import org.smartdata.hdfs.HadoopUtil; import org.smartdata.protocol.message.StatusMessage; import org.smartdata.protocol.message.StatusReporter; import org.smartdata.server.engine.cmdlet.CmdletExecutor; import org.smartdata.server.engine.cmdlet.StatusReportTask; import org.smartdata.server.engine.cmdlet.agent.AgentCmdletService; import org.smartdata.server.engine.cmdlet.agent.AgentConstants; import org.smartdata.server.engine.cmdlet.agent.AgentUtils; import org.smartdata.server.engine.cmdlet.agent.SmartAgentContext; import org.smartdata.server.engine.cmdlet.agent.messages.AgentToMaster.RegisterNewAgent; import org.smartdata.server.engine.cmdlet.agent.messages.MasterToAgent; import org.smartdata.server.engine.cmdlet.agent.messages.MasterToAgent.AgentRegistered; import org.smartdata.server.utils.GenericOptionsParser; import org.smartdata.utils.SecurityUtil; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Deque; import java.util.LinkedList; import java.util.UUID; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import scala.concurrent.duration.Duration; import scala.concurrent.duration.FiniteDuration; public class SmartAgent implements StatusReporter { private static final String NAME = "SmartAgent"; private static final Logger LOG = LoggerFactory.getLogger(SmartAgent.class); private ActorSystem system; private ActorRef agentActor; private CmdletExecutor cmdletExecutor; public static void main(String[] args) throws IOException { SmartAgent agent = new SmartAgent(); SmartConf conf = (SmartConf) new GenericOptionsParser( new SmartConf(), args).getConfiguration(); String[] masters = AgentUtils.getMasterAddress(conf); if (masters == null) { throw new IOException("No master address found!"); } for (int i = 0; i < masters.length; i++) { LOG.info("Agent master " + i + ": " + masters[i]); } String agentAddress = AgentUtils.getAgentAddress(conf); LOG.info("Agent address: " + agentAddress); RegisterNewAgent.getInstance( "SSMAgent@" + agentAddress.replaceAll(":.*$", "")); HadoopUtil.setSmartConfByHadoop(conf); agent.authentication(conf); agent.start(AgentUtils.overrideRemoteAddress( ConfigFactory.load(AgentConstants.AKKA_CONF_FILE), agentAddress), AgentUtils.getMasterActorPaths(masters), conf); } //TODO: remove loadHadoopConf private void authentication(SmartConf conf) throws IOException { if (!SecurityUtil.isSecurityEnabled(conf)) { return; } // Load Hadoop configuration files try { HadoopUtil.loadHadoopConf(conf); } catch (IOException e) { LOG.info("Running in secure mode, but cannot find Hadoop " + "configuration file. Please config smart.hadoop.conf.path " + "property in smart-site.xml."); conf.set("hadoop.security.authentication", "kerberos"); conf.set("hadoop.security.authorization", "true"); } UserGroupInformation.setConfiguration(conf); String keytabFilename = conf.get(SmartConfKeys.SMART_AGENT_KEYTAB_FILE_KEY); String principalConfig = conf.get(SmartConfKeys.SMART_AGENT_KERBEROS_PRINCIPAL_KEY); String principal = org.apache.hadoop.security.SecurityUtil.getServerPrincipal( principalConfig, (String) null); SecurityUtil.loginUsingKeytab(keytabFilename, principal); } private static String getDateString() { Date now = new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); return df.format(now); } public void start(Config config, String[] masterPath, SmartConf conf) { system = ActorSystem.apply(NAME, config); agentActor = system.actorOf(Props.create( AgentActor.class, this, masterPath, conf), getAgentName()); final Thread currentThread = Thread.currentThread(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { shutdown(); try { currentThread.join(); } catch (InterruptedException e) { // Ignore } } }); Services.init(new SmartAgentContext(conf, this)); Services.start(); AgentCmdletService agentCmdletService = (AgentCmdletService) Services.getService( SmartConstants.AGENT_CMDLET_SERVICE_NAME); cmdletExecutor = agentCmdletService.getCmdletExecutor(); ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); int reportPeriod = conf.getInt(SmartConfKeys.SMART_STATUS_REPORT_PERIOD_KEY, SmartConfKeys.SMART_STATUS_REPORT_PERIOD_DEFAULT); StatusReportTask statusReportTask = new StatusReportTask(this, cmdletExecutor, conf); executorService.scheduleAtFixedRate( statusReportTask, 1000, reportPeriod, TimeUnit.MILLISECONDS); system.awaitTermination(); } public void shutdown() { Services.stop(); if (system != null && !system.isTerminated()) { LOG.info("Shutting down system {}", AgentUtils.getSystemAddres(system)); system.shutdown(); } } /** * Deliver status message to agent actor. The message will be handled by * {@link AgentActor.Serve#apply method}. */ @Override public void report(StatusMessage status) { Patterns.ask(agentActor, status, Timeout.apply(5, TimeUnit.SECONDS)); } private String getAgentName() { return "agent-" + UUID.randomUUID().toString(); } /** * Agent Actor behaves like a state machine. It has a concept of context * which can be viewed as a kind of agent status. And one context can be * shifted to another. Under a specific context, some methods are defined * to tell agent what to do. * * <p>1. After agent starts, the context becomes {@code WaitForFindMaster}. * Under this context, agent will try to find agent master (@see AgentMaster) * and {@link WaitForFindMaster#apply apply method} will tackle message * from master. After master is found, the context will be shifted to * {@code WaitForRegisterAgent}. * * <p>2. In {@code WaitForRegisterAgent} context, agent will send {@code * RegisterNewAgent} message to master. And {@link WaitForRegisterAgent#apply * apply method} will tackle message from master. A unique agent id is * contained in the message of master. After the tackling, the context * becomes {@code Serve}. * * <p>3. In {@code Serve} context, agent is in active service to respond * to master's request of executing SSM action wrapped in master's message. * In this context, if agent loses connection with master, the context will * go back to {@code WaitForRegisterAgent}. And agent will go through the * above procedure again. */ static class AgentActor extends UntypedActor { private static final Logger LOG = LoggerFactory.getLogger(AgentActor.class); private static final FiniteDuration TIMEOUT = Duration.create(30, TimeUnit.SECONDS); private static final FiniteDuration RETRY_INTERVAL = Duration.create(2, TimeUnit.SECONDS); private MasterToAgent.AgentId id; private ActorRef master; private final SmartAgent agent; private final String[] masters; private SmartConf conf; private Deque<Object> unhandledMessages = new LinkedList<>(); public AgentActor(SmartAgent agent, String[] masters, SmartConf conf) { this.agent = agent; this.masters = masters; this.conf = conf; } @Override public void onReceive(Object message) throws Exception { unhandled(message); } /** * Subscribe an event: {@code DisassociatedEvent}. It will be handled by * {@link WaitForRegisterAgent#apply method} and {@link Serve#apply method}. */ @Override public void preStart() { Cancellable findMaster = findMaster(); getContext().become(new WaitForFindMaster(findMaster)); this.context().system().eventStream().subscribe( self(), DisassociatedEvent.class); } /** * Find master by trying to send message to configured smart servers one * by one. The retry interval value and timeout value are specified above. * * <p>Agent will find a new master if current master crashes, so before * that, agent need unwatch crashed master to avoid trying re-association. */ private Cancellable findMaster() { if (master != null) { LOG.info("Before finding master, unwatch current master: " + master.path().address()); this.context().unwatch(master); master = null; } return AgentUtils.repeatActionUntil(getContext().system(), Duration.Zero(), RETRY_INTERVAL, TIMEOUT, new Runnable() { @Override public void run() { for (String m : masters) { // Pick up one possible master server and send message to it. final ActorSelection actorSelection = getContext().actorSelection(m); actorSelection.tell(new Identify(null), getSelf()); } } }, new Shutdown(agent)); } /** * Cache {@code AgentService.Message} or {@code StatusMessage}. * * <p>Association error message can be sent repeatedly. We * only need to cache messages related to SSM. */ public void cacheMessage(Object message) { if (message instanceof AgentService.Message || message instanceof StatusMessage) { unhandledMessages.addLast(message); } } private class WaitForFindMaster implements Procedure<Object> { private final Cancellable findMaster; public WaitForFindMaster(Cancellable findMaster) { this.findMaster = findMaster; } /** * If agent disassociated with master, it will go back to this * context to find a new master. But cmdlet report message can * be delivered to it during this procedure. So we keep such * message in {@code unhandledMessages} */ @Override public void apply(Object message) throws Exception { if (message instanceof ActorIdentity) { ActorIdentity identity = (ActorIdentity) message; master = identity.getRef(); if (master != null) { findMaster.cancel(); // Set smart server rpc address in conf, thus SmartDFSClient // will be instantiated with this address. String rpcHost = master.path().address().host().get(); String rpcPort = conf .get(SmartConfKeys.SMART_SERVER_RPC_ADDRESS_KEY, SmartConfKeys.SMART_SERVER_RPC_ADDRESS_DEFAULT) .split(":")[1]; conf.set(SmartConfKeys.SMART_SERVER_RPC_ADDRESS_KEY, rpcHost + ":" + rpcPort); Cancellable registerAgent = AgentUtils.repeatActionUntil(getContext().system(), Duration.Zero(), RETRY_INTERVAL, TIMEOUT, new SendMessage(master, RegisterNewAgent.getInstance()), new Shutdown(agent)); LOG.info("Registering to master {}", master); getContext().become(new WaitForRegisterAgent(registerAgent)); } } else { // Association error message can be received when agent is trying to // connect to an unready master. Only messages related to SSM need to // be cached and handled when agent is ready. cacheMessage(message); } } } private class WaitForRegisterAgent implements Procedure<Object> { private final Cancellable registerAgent; public WaitForRegisterAgent(Cancellable registerAgent) { this.registerAgent = registerAgent; } /** * Disassociation can occur during agent wait for the registry. So if * {@code DisassociatedEvent} is received, the context will become the * preceding one to find master. * * <p>Since agent may disassociate with master during running SSM tasks, * cmdlet status report can be delivered under this context. Similar to * the last context, use a deque {@code unhandledMessages} to keep such * message. */ @Override public void apply(Object message) throws Exception { if (message instanceof AgentRegistered) { AgentRegistered registered = (AgentRegistered) message; registerAgent.cancel(); // Watch master and listen messages delivered from it. getContext().watch(master); AgentActor.this.id = registered.getAgentId(); LOG.info("SmartAgent {} registered to master: {}", AgentActor.this.id, master.path().address()); Serve serveContext = new Serve(); getContext().become(serveContext); } else if (message instanceof DisassociatedEvent) { AssociationEvent associEvent = (AssociationEvent) message; // Event for failed master can be repeated published. We can ignore it. if (!master.path().address().equals( associEvent.remoteAddress())) { return; } LOG.warn("Received event: {}, details: {}", associEvent.eventName(), associEvent.toString()); LOG.warn("Go back to the preceding context to find master.."); getContext().become(new WaitForFindMaster(findMaster())); } else { cacheMessage(message); } } } private class Serve implements Procedure<Object> { /** * To handle messages according to the receiving order, the unhandled * messages should be applied firstly. So we do this in the instantiation * of {@code Serve}. And for messages kept in {@code unhandledMessages}, * FIFO rule is complied. */ public Serve() { applyUnhandledMessage(); } private void applyUnhandledMessage() { if (unhandledMessages.isEmpty()) { return; } LOG.info("Applying {} unhandled message(s)...", unhandledMessages.size()); while (unhandledMessages.size() != 0) { Object message = unhandledMessages.pollFirst(); try { this.apply(message); } catch (Exception e) { LOG.warn("Failed to handle message: " + message.toString() + "Reason: " + e.getMessage()); } } } /** * If master exits gracefully, for example, using 'kill PID' to make * master precess exit, {@code Terminated} message can be received * immediately. But a more general scenario is that master node crashes * abruptly (mocked by 'kill -9 PID') while agent has dead letters * (e.g., cmdlet status report). Under this scenario, agent will spend * around 30min to try to associate with master and deliver letters. So * we enable agent subscribe and listen {@code DisassociatedEvent}. See * {@link AgentActor#preStart prestart}. The context will be shifted to * find new master if this event is received. */ @Override public void apply(Object message) throws Exception { if (message instanceof AgentService.Message) { try { Services.dispatch((AgentService.Message) message); } catch (Exception e) { LOG.error(e.getMessage()); } } else if (message instanceof StatusMessage) { master.tell(message, getSelf()); getSender().tell("status reported", getSelf()); } else if (message instanceof Terminated) { Terminated terminated = (Terminated) message; if (terminated.getActor().equals(master)) { // Go back to WaitForFindMaster context to find new master. LOG.warn("Lost association with master {}. Try to register to " + "a new master...", getSender()); getContext().become(new WaitForFindMaster(findMaster())); } } else if (message instanceof DisassociatedEvent) { AssociationEvent associEvent = (AssociationEvent) message; // Event for failed master can be repeated published. So ignore it. if (!master.path().address().equals( associEvent.remoteAddress())) { return; } LOG.warn("Received event: {}, details: {}", associEvent.eventName(), associEvent.toString()); LOG.warn("Try to register to a new master..."); getContext().become(new WaitForFindMaster(findMaster())); } else { LOG.warn("Unhandled message: " + message.toString()); } } } private class SendMessage implements Runnable { private final ActorRef to; private final Object message; public SendMessage(ActorRef to, Object message) { this.to = to; this.message = message; } @Override public void run() { to.tell(message, getSelf()); } } private class Shutdown implements Runnable { private SmartAgent agent; public Shutdown(SmartAgent agent) { this.agent = agent; } /** * {@link SmartAgent#shutdown() shutdown} will be called before * the program exits. */ @Override public void run() { getSelf().tell(PoisonPill.getInstance(), ActorRef.noSender()); LOG.info("Failed to find master after {}, shutting down...", TIMEOUT); // Now that akka actor will not work, no need to keep program alive. System.exit(-1); } } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-agent/src/main/java/org/smartdata/agent/Services.java
smart-agent/src/main/java/org/smartdata/agent/Services.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.agent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartdata.AgentService; import org.smartdata.SmartContext; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; public class Services { private static final Logger LOG = LoggerFactory.getLogger(Services.class); private static Map<String, AgentService> services = new HashMap<>(); static { try { ServiceLoader<AgentService> loaded = ServiceLoader.load(AgentService.class); for (AgentService service: loaded) { services.put(service.getServiceName(), service); } } catch (ServiceConfigurationError e) { LOG.error("Load services failed from factory"); } } private Services() {} public static AgentService getService(String name) { return services.get(name); } public static void dispatch(AgentService.Message message) throws Exception { AgentService service = services.get(message.getServiceName()); service.execute(message); } public static void init(SmartContext context) { for (Map.Entry<String, AgentService> entry: services.entrySet()) { try { AgentService service = entry.getValue(); service.setContext(context); service.init(); } catch (IOException e) { LOG.error("Service {} failed to init", entry.getKey()); } } } public static void start() { for (Map.Entry<String, AgentService> entry: services.entrySet()) { try { AgentService service = entry.getValue(); service.start(); } catch (IOException e) { LOG.error("Service {} failed to start", entry.getKey()); } } } public static void stop() { for (Map.Entry<String, AgentService> entry: services.entrySet()) { try { AgentService service = entry.getValue(); service.stop(); } catch (IOException e) { LOG.error("Service {} failed to stop", entry.getKey()); } } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/MiniClusterFactory31.java
smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/MiniClusterFactory31.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.hdfs; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.StorageType; import org.apache.hadoop.hdfs.MiniDFSCluster; import java.io.IOException; public class MiniClusterFactory31 extends MiniClusterFactory { @Override public MiniDFSCluster create(int dataNodes, Configuration conf) throws IOException { return new MiniDFSCluster.Builder(conf) .numDataNodes(dataNodes) .build(); } @Override public MiniDFSCluster createWithStorages(int dataNodes, Configuration conf) throws IOException { return new MiniDFSCluster.Builder(conf) .numDataNodes(dataNodes) .storagesPerDatanode(3) .storageTypes(new StorageType[]{StorageType.DISK, StorageType.ARCHIVE, StorageType.SSD}) .build(); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/action/TestUnErasureCodingAction.java
smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/action/TestUnErasureCodingAction.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.hdfs.action; import org.apache.hadoop.fs.Path; import static org.junit.Assert.*; import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; import org.junit.Test; import java.util.HashMap; import java.util.Map; public class TestUnErasureCodingAction extends TestErasureCodingMiniCluster { @Test public void testUnEcActionForFile() throws Exception { String testDir = "/test_dir"; dfs.mkdirs(new Path(testDir)); dfs.setErasureCodingPolicy(new Path(testDir), ecPolicy.getName()); // create test file, its EC policy should be consistent with parent dir, i.e., ecPolicy. String srcPath = testDir + "/ec_file"; createTestFile(srcPath, 1000); dfsClient.setStoragePolicy(srcPath, "COLD"); HdfsFileStatus srcFileStatus = dfsClient.getFileInfo(srcPath); assertEquals(dfsClient.getErasureCodingPolicy(srcPath), ecPolicy); UnErasureCodingAction unEcAction = new UnErasureCodingAction(); unEcAction.setContext(smartContext); String ecTmpPath = "/ssm/ec_tmp/tmp_file"; Map<String, String> args = new HashMap<>(); args.put(HdfsAction.FILE_PATH, srcPath); args.put(ErasureCodingBase.EC_TMP, ecTmpPath); unEcAction.init(args); unEcAction.run(); assertTrue(unEcAction.getExpectedAfterRun()); HdfsFileStatus fileStatus = dfsClient.getFileInfo(srcPath); assertNull(fileStatus.getErasureCodingPolicy()); // Examine the consistency of file attributes. assertEquals(srcFileStatus.getLen(), fileStatus.getLen()); assertEquals(srcFileStatus.getModificationTime(), fileStatus.getModificationTime()); assertEquals(srcFileStatus.getAccessTime(), fileStatus.getAccessTime()); assertEquals(srcFileStatus.getOwner(), fileStatus.getOwner()); assertEquals(srcFileStatus.getGroup(), fileStatus.getGroup()); assertEquals(srcFileStatus.getPermission(), fileStatus.getPermission()); // UNDEF storage policy makes the converted file's storage type uncertain, so it is excluded. if (srcFileStatus.getStoragePolicy() != 0) { assertEquals(srcFileStatus.getStoragePolicy(), fileStatus.getStoragePolicy()); } } @Test public void testUnEcActionForDir() throws Exception { String testDir = "/test_dir"; dfs.mkdirs(new Path(testDir)); dfs.setErasureCodingPolicy(new Path(testDir), ecPolicy.getName()); assertEquals(dfsClient.getErasureCodingPolicy(testDir), ecPolicy); UnErasureCodingAction unEcAction = new UnErasureCodingAction(); unEcAction.setContext(smartContext); Map<String, String> args = new HashMap<>(); args.put(HdfsAction.FILE_PATH, testDir); unEcAction.init(args); unEcAction.run(); assertNull(dfs.getErasureCodingPolicy(new Path(testDir))); // Create test file, its EC policy is expected to be replication. String srcPath = testDir + "/ec_file"; createTestFile(srcPath, 1000); assertNull(dfs.getErasureCodingPolicy(new Path(srcPath))); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/action/TestErasureCodingAction.java
smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/action/TestErasureCodingAction.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.hdfs.action; import org.apache.hadoop.fs.Path; import static org.junit.Assert.*; import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; import org.junit.Test; import java.util.HashMap; import java.util.Map; public class TestErasureCodingAction extends TestErasureCodingMiniCluster { @Test public void testEcActionForFile() throws Exception { String srcPath = "/ec/test_file"; // Small file is not stored in EC way. createTestFile(srcPath, 100000000); dfsClient.setStoragePolicy(srcPath, "COLD"); HdfsFileStatus srcFileStatus = dfsClient.getFileInfo(srcPath); // The file is expected to be stored in replication. assertEquals(null, srcFileStatus.getErasureCodingPolicy()); ErasureCodingAction ecAction = new ErasureCodingAction(); ecAction.setContext(smartContext); String ecTmpPath = "/ssm/ec_tmp/tmp_file"; Map<String, String> args = new HashMap<>(); args.put(HdfsAction.FILE_PATH, srcPath); args.put(ErasureCodingBase.EC_TMP, ecTmpPath); args.put(ErasureCodingAction.EC_POLICY_NAME, ecPolicy.getName()); ecAction.init(args); ecAction.run(); assertTrue(ecAction.getExpectedAfterRun()); HdfsFileStatus fileStatus = dfsClient.getFileInfo(srcPath); // The file is expected to be stored in EC with default policy. assertEquals(ecPolicy, fileStatus.getErasureCodingPolicy()); // Examine the consistency of file attributes. assertEquals(srcFileStatus.getLen(), fileStatus.getLen()); assertEquals(srcFileStatus.getModificationTime(), fileStatus.getModificationTime()); assertEquals(srcFileStatus.getAccessTime(), fileStatus.getAccessTime()); assertEquals(srcFileStatus.getOwner(), fileStatus.getOwner()); assertEquals(srcFileStatus.getGroup(), fileStatus.getGroup()); assertEquals(srcFileStatus.getPermission(), fileStatus.getPermission()); // UNDEF storage policy makes the converted file's storage type uncertain, so it is excluded. if (srcFileStatus.getStoragePolicy() != 0) { // To make sure the consistency of storage policy assertEquals(srcFileStatus.getStoragePolicy(), fileStatus.getStoragePolicy()); } } @Test public void testEcActionForDir() throws Exception { String srcDirPath = "/test_dir/"; dfs.mkdirs(new Path(srcDirPath)); assertEquals(null, dfsClient.getErasureCodingPolicy(srcDirPath)); ErasureCodingAction ecAction = new ErasureCodingAction(); ecAction.setContext(smartContext); Map<String, String> args = new HashMap<>(); args.put(HdfsAction.FILE_PATH, srcDirPath); args.put(ErasureCodingAction.EC_POLICY_NAME, ecPolicy.getName()); ecAction.init(args); ecAction.run(); assertTrue(ecAction.getExpectedAfterRun()); assertEquals(dfsClient.getErasureCodingPolicy(srcDirPath), ecPolicy); String srcFilePath = "/test_dir/test_file"; createTestFile(srcFilePath, 1000); // The newly created file should has the same EC policy as parent directory. assertEquals(dfsClient.getErasureCodingPolicy(srcFilePath), ecPolicy); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/action/TestErasureCodingMiniCluster.java
smart-hadoop-support/smart-hadoop-3.1/src/test/java/org/smartdata/hdfs/action/TestErasureCodingMiniCluster.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.hdfs.action; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hdfs.*; import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy; import org.apache.hadoop.hdfs.protocol.SystemErasureCodingPolicies; import org.junit.After; import org.junit.Before; import org.smartdata.SmartContext; import org.smartdata.conf.SmartConf; import org.smartdata.conf.SmartConfKeys; import org.smartdata.hdfs.MiniClusterFactory; import java.io.IOException; public class TestErasureCodingMiniCluster { protected ErasureCodingPolicy ecPolicy; // use the default one, not the one in MiniClusterHarness public static final long BLOCK_SIZE = DFSConfigKeys.DFS_BLOCK_SIZE_DEFAULT; protected MiniDFSCluster cluster; protected DistributedFileSystem dfs; protected DFSClient dfsClient; protected SmartContext smartContext; @Before public void init() throws Exception { SmartConf conf = new SmartConf(); conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_SIZE); conf.setLong(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY, DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_DEFAULT); conf.setInt(DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_KEY, DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_DEFAULT); // use ErasureCodeConstants.XOR_2_1_SCHEMA ecPolicy = SystemErasureCodingPolicies.getPolicies().get(3); cluster = MiniClusterFactory.get(). createWithStorages(ecPolicy.getNumDataUnits() + ecPolicy.getNumParityUnits(), conf); // Add namenode URL to smartContext conf.set(SmartConfKeys.SMART_DFS_NAMENODE_RPCSERVER_KEY, "hdfs://" + cluster.getNameNode().getNameNodeAddressHostPortString()); smartContext = new SmartContext(conf); cluster.waitActive(); dfs = cluster.getFileSystem(); dfsClient = dfs.getClient(); dfsClient.enableErasureCodingPolicy(ecPolicy.getName()); } public void createTestFile(String srcPath, long length) throws IOException { // DFSTestUtil.createFile(dfs, new Path(srcPath), length, (short) 3, 0L); DFSTestUtil.createFile(dfs, new Path(srcPath), 1024, length, BLOCK_SIZE, (short) 3, 0L); } @After public void shutdown() throws IOException { if (cluster != null) { cluster.shutdown(); } } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/apache/hadoop/hdfs/CompactInputStream.java
smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/apache/hadoop/hdfs/CompactInputStream.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.hdfs; import org.apache.hadoop.fs.ReadOption; import org.apache.hadoop.hdfs.protocol.LocatedBlock; import org.apache.hadoop.io.ByteBufferPool; import org.smartdata.model.CompactFileState; import org.smartdata.model.FileContainerInfo; import org.smartdata.model.FileState; import java.io.EOFException; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; public class CompactInputStream extends SmartInputStream { private FileContainerInfo fileContainerInfo; private boolean closed = false; private static final String INHERITED_CLASS = "org.apache.hadoop.hdfs.DFSInputStream"; CompactInputStream(DFSClient dfsClient, boolean verifyChecksum, FileState fileState) throws IOException { super(dfsClient, ((CompactFileState) fileState).getFileContainerInfo().getContainerFilePath(), verifyChecksum, fileState); this.fileContainerInfo = ((CompactFileState) fileState).getFileContainerInfo(); super.seek(fileContainerInfo.getOffset()); } @Override public long getFileLength() { String callerClass = Thread.currentThread().getStackTrace()[2].getClassName(); if (INHERITED_CLASS.equals(callerClass)) { return fileContainerInfo.getLength() + fileContainerInfo.getOffset(); } else { return fileContainerInfo.getLength(); } } @Override public List<LocatedBlock> getAllBlocks() throws IOException { List<LocatedBlock> blocks = super.getAllBlocks(); List<LocatedBlock> ret = new ArrayList<>(16); long off = fileContainerInfo.getOffset(); long len = fileContainerInfo.getLength(); for (LocatedBlock b : blocks) { if (off > b.getStartOffset() + b.getBlockSize() || off + len < b.getStartOffset()) { continue; } ret.add(b); } return ret; } @Override public synchronized int read(final byte[] buf, int off, int len) throws IOException { int realLen = (int) Math.min(len, fileContainerInfo.getLength() - getPos()); if (realLen == 0) { return -1; } else { return super.read(buf, off, realLen); } } @Override public synchronized int read(final ByteBuffer buf) throws IOException { int realLen = (int) Math.min(buf.remaining(), fileContainerInfo.getLength() - getPos()); if (realLen == 0) { return -1; } else { buf.limit(realLen + buf.position()); return super.read(buf); } } @Override public int read(long position, byte[] buffer, int offset, int length) throws IOException { long realPos = position + fileContainerInfo.getOffset(); int realLen = (int) Math.min(length, fileContainerInfo.getLength() - position); if (realLen == 0) { return -1; } else { return super.read(realPos, buffer, offset, realLen); } } @Override public synchronized long getPos() { String callerClass = Thread.currentThread().getStackTrace()[2].getClassName(); if (INHERITED_CLASS.equals(callerClass)) { return super.getPos(); } else { return super.getPos() - fileContainerInfo.getOffset(); } } @Override public synchronized int available() throws IOException { if (closed) { throw new IOException("Stream closed."); } final long remaining = getFileLength() - getPos(); return remaining <= Integer.MAX_VALUE ? (int) remaining : Integer.MAX_VALUE; } @Override public synchronized void seek(long targetPos) throws IOException { String callerClass = Thread.currentThread().getStackTrace()[2].getClassName(); if (INHERITED_CLASS.equals(callerClass)) { super.seek(targetPos); } else { if (targetPos > fileContainerInfo.getLength()) { throw new EOFException("Cannot seek after EOF"); } if (targetPos < 0) { throw new EOFException("Cannot seek to negative offset"); } super.seek(fileContainerInfo.getOffset() + targetPos); } } @Override public synchronized boolean seekToNewSource(long targetPos) throws IOException { String callerClass = Thread.currentThread().getStackTrace()[2].getClassName(); if (INHERITED_CLASS.equals(callerClass)) { return super.seekToNewSource(targetPos); } else { if (targetPos < 0) { throw new EOFException("Cannot seek after EOF"); } else { return super.seekToNewSource(fileContainerInfo.getOffset() + targetPos); } } } @Override public synchronized void setReadahead(Long readahead) throws IOException { long realReadAhead = Math.min(readahead, fileContainerInfo.getLength() - getPos()); super.setReadahead(realReadAhead); } @Override public synchronized ByteBuffer read(ByteBufferPool bufferPool, int maxLength, EnumSet<ReadOption> opts) throws IOException, UnsupportedOperationException { int realMaxLen = (int) Math.min(maxLength, fileContainerInfo.getLength() - getPos()); return super.read(bufferPool, realMaxLen, opts); } @Override public synchronized void close() throws IOException { super.close(); this.closed = true; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/apache/hadoop/hdfs/SmartStripedInputStream.java
smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/apache/hadoop/hdfs/SmartStripedInputStream.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.hdfs; import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy; import org.apache.hadoop.hdfs.protocol.LocatedBlocks; import org.smartdata.model.FileState; import java.io.IOException; public class SmartStripedInputStream extends DFSStripedInputStream { FileState fileState; public SmartStripedInputStream(DFSClient dfsClient, String src, boolean verifyChecksum, ErasureCodingPolicy ecPolicy, LocatedBlocks locatedBlocks, FileState fileState) throws IOException { super(dfsClient, src, verifyChecksum, ecPolicy, locatedBlocks); this.fileState = fileState; } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/apache/hadoop/hdfs/SmartInputStream.java
smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/apache/hadoop/hdfs/SmartInputStream.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hadoop.hdfs; import org.smartdata.model.FileState; import java.io.IOException; /** * DFSInputStream for SSM. */ public class SmartInputStream extends DFSInputStream { protected final FileState fileState; public SmartInputStream(DFSClient dfsClient, String src, boolean verifyChecksum, FileState fileState) throws IOException { super(dfsClient, src, verifyChecksum, dfsClient.getLocatedBlocks(src, 0)); this.fileState = fileState; } public FileState.FileType getType() { return fileState.getFileType(); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false
Intel-bigdata/SSM
https://github.com/Intel-bigdata/SSM/blob/e0c90f054687a18c4e095547ac5e31b8b313b3ef/smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/smartdata/hdfs/CompatibilityHelper31.java
smart-hadoop-support/smart-hadoop-3.1/src/main/java/org/smartdata/hdfs/CompatibilityHelper31.java
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.smartdata.hdfs; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.*; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.DFSClient; import org.apache.hadoop.hdfs.DFSInputStream; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.SmartInputStream; import org.apache.hadoop.hdfs.SmartStripedInputStream; import org.apache.hadoop.hdfs.inotify.Event; import org.apache.hadoop.hdfs.protocol.*; import org.apache.hadoop.hdfs.protocol.datatransfer.Sender; import org.apache.hadoop.hdfs.protocol.proto.InotifyProtos; import org.apache.hadoop.hdfs.protocolPB.PBHelperClient; import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier; import org.apache.hadoop.hdfs.server.balancer.KeyManager; import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor; import org.apache.hadoop.hdfs.server.namenode.ErasureCodingPolicyManager; import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage; import org.apache.hadoop.hdfs.server.protocol.StorageReport; import org.apache.hadoop.security.token.Token; import org.smartdata.SmartConstants; import org.smartdata.hdfs.action.move.DBlock; import org.smartdata.hdfs.action.move.StorageGroup; import org.smartdata.hdfs.action.move.DBlockStriped; import org.smartdata.model.FileState; import java.io.*; import java.net.URI; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; public class CompatibilityHelper31 implements CompatibilityHelper { @Override public String[] getStorageTypes(LocatedBlock lb) { List<String> types = new ArrayList<>(); for (StorageType type : lb.getStorageTypes()) { types.add(type.toString()); } return types.toArray(new String[types.size()]); } @Override public void replaceBlock( DataOutputStream out, ExtendedBlock eb, String storageType, Token<BlockTokenIdentifier> accessToken, String dnUUID, DatanodeInfo info) throws IOException { new Sender(out).replaceBlock(eb, StorageType.valueOf(storageType), accessToken, dnUUID, info, null); } @Override public String[] getMovableTypes() { List<String> types = new ArrayList<>(); for (StorageType type : StorageType.getMovableTypes()) { types.add(type.toString()); } return types.toArray(new String[types.size()]); } @Override public String getStorageType(StorageReport report) { return report.getStorage().getStorageType().toString(); } @Override public List<String> chooseStorageTypes(BlockStoragePolicy policy, short replication) { List<String> types = new ArrayList<>(); for (StorageType type : policy.chooseStorageTypes(replication)) { types.add(type.toString()); } return types; } @Override public boolean isMovable(String type) { return StorageType.valueOf(type).isMovable(); } @Override public DatanodeInfo newDatanodeInfo(String ipAddress, int xferPort) { DatanodeID datanodeID = new DatanodeID(ipAddress, null, null, xferPort, 0, 0, 0); DatanodeDescriptor datanodeDescriptor = new DatanodeDescriptor(datanodeID); return datanodeDescriptor; } @Override public InotifyProtos.AppendEventProto getAppendEventProto(Event.AppendEvent event) { return InotifyProtos.AppendEventProto.newBuilder() .setPath(event.getPath()) .setNewBlock(event.toNewBlock()).build(); } @Override public Event.AppendEvent getAppendEvent(InotifyProtos.AppendEventProto proto) { return new Event.AppendEvent.Builder().path(proto.getPath()) .newBlock(proto.hasNewBlock() && proto.getNewBlock()) .build(); } @Override public boolean truncate(DFSClient client, String src, long newLength) throws IOException { return client.truncate(src, newLength); } @Override public boolean truncate(DistributedFileSystem fileSystem, String src, long newLength) throws IOException { return fileSystem.truncate(new Path(src), newLength); } @Override public int getSidInDatanodeStorageReport(DatanodeStorage datanodeStorage) { StorageType storageType = datanodeStorage.getStorageType(); return storageType.ordinal(); } @Override public OutputStream getDFSClientAppend(DFSClient client, String dest, int buffersize, long offset) throws IOException { if (client.exists(dest) && offset != 0) { return getDFSClientAppend(client, dest, buffersize); } return client.create(dest, true); } @Override public OutputStream getDFSClientAppend(DFSClient client, String dest, int buffersize) throws IOException { return client .append(dest, buffersize, EnumSet.of(CreateFlag.APPEND), null, null); } @Override public OutputStream getS3outputStream(String dest, Configuration conf) throws IOException { // Copy to remote S3 if (!dest.startsWith("s3")) { throw new IOException(); } // Copy to s3 org.apache.hadoop.fs.FileSystem fs = org.apache.hadoop.fs.FileSystem.get(URI.create(dest), conf); return fs.create(new Path(dest), true); } @Override public int getReadTimeOutConstant() { return HdfsConstants.READ_TIMEOUT; } @Override public Token<BlockTokenIdentifier> getAccessToken( KeyManager km, ExtendedBlock eb, StorageGroup target) throws IOException { return km.getAccessToken(eb, new StorageType[]{StorageType.parseStorageType(target.getStorageType())}, new String[0]); } @Override public int getIOFileBufferSize(Configuration conf) { return conf.getInt(CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY, CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT); } @Override public InputStream getVintPrefixed(DataInputStream in) throws IOException { return PBHelperClient.vintPrefixed(in); } @Override public LocatedBlocks getLocatedBlocks(HdfsLocatedFileStatus status) { return status.getLocatedBlocks(); } @Override public HdfsFileStatus createHdfsFileStatus( long length, boolean isdir, int block_replication, long blocksize, long modification_time, long access_time, FsPermission permission, String owner, String group, byte[] symlink, byte[] path, long fileId, int childrenNum, FileEncryptionInfo feInfo, byte storagePolicy) { return new HdfsFileStatus.Builder() .length(length) .isdir(isdir) .replication(block_replication) .blocksize(blocksize) .mtime(modification_time) .atime(access_time) .perm(permission) .owner(owner) .group(group) .symlink(symlink) .path(path) .fileId(fileId) .children(childrenNum) .feInfo(feInfo) .storagePolicy(storagePolicy) .build(); } @Override public byte getErasureCodingPolicy(HdfsFileStatus fileStatus) { ErasureCodingPolicy erasureCodingPolicy = fileStatus.getErasureCodingPolicy(); // null means replication policy and its id is 0 in HDFS. if (erasureCodingPolicy == null) { return (byte) 0; } return fileStatus.getErasureCodingPolicy().getId(); } @Override public String getErasureCodingPolicyName(HdfsFileStatus fileStatus) { ErasureCodingPolicy erasureCodingPolicy = fileStatus.getErasureCodingPolicy(); if (erasureCodingPolicy == null) { return SmartConstants.REPLICATION_CODEC_NAME; } return erasureCodingPolicy.getName(); } @Override public byte getErasureCodingPolicyByName(DFSClient client, String ecPolicyName) throws IOException { if (ecPolicyName.equals(SystemErasureCodingPolicies.getReplicationPolicy().getName())) { return (byte) 0; } for (ErasureCodingPolicyInfo policyInfo : client.getErasureCodingPolicies()) { if (policyInfo.getPolicy().getName().equals(ecPolicyName)) { return policyInfo.getPolicy().getId(); } } return (byte) -1; } @Override public Map<Byte, String> getErasureCodingPolicies(DFSClient dfsClient) throws IOException { Map<Byte, String> policies = new HashMap<>(); /** * The replication policy is excluded by the get method of client, * but it should also be put. Its id is always 0. */ policies.put((byte) 0, SystemErasureCodingPolicies.getReplicationPolicy().getName()); for (ErasureCodingPolicyInfo policyInfo : dfsClient.getErasureCodingPolicies()) { ErasureCodingPolicy policy = policyInfo.getPolicy(); policies.put(policy.getId(), policy.getName()); } return policies; } @Override public List<String> getStorageTypeForEcBlock( LocatedBlock lb, BlockStoragePolicy policy, byte policyId) throws IOException { if (lb.isStriped()) { //TODO: verify the current storage policy (policyID) or the target one //TODO: output log for unsupported storage policy for EC block String policyName = policy.getName(); // Exclude onessd/onedisk action to be executed on EC block. // EC blocks can only be put on a same storage medium. if (policyName.equalsIgnoreCase("Warm") | policyName.equalsIgnoreCase("One_SSD") | policyName.equalsIgnoreCase("Lazy_Persist")) { throw new IOException("onessd/onedisk/ramdisk is not applicable to EC block!"); } if (ErasureCodingPolicyManager .checkStoragePolicySuitableForECStripedMode(policyId)) { return chooseStorageTypes(policy, (short) lb.getLocations().length); } else { throw new IOException("Unsupported storage policy for EC block: " + policy.getName()); } } return null; } @Override public DBlock newDBlock(LocatedBlock lb, HdfsFileStatus status) { Block blk = lb.getBlock().getLocalBlock(); ErasureCodingPolicy ecPolicy = status.getErasureCodingPolicy(); DBlock db; if (lb.isStriped()) { LocatedStripedBlock lsb = (LocatedStripedBlock) lb; byte[] indices = new byte[lsb.getBlockIndices().length]; for (int i = 0; i < indices.length; i++) { indices[i] = (byte) lsb.getBlockIndices()[i]; } db = (DBlock) new DBlockStriped(blk, indices, (short) ecPolicy.getNumDataUnits(), ecPolicy.getCellSize()); } else { db = new DBlock(blk); } return db; } @Override public boolean isLocatedStripedBlock(LocatedBlock lb) { return lb instanceof LocatedStripedBlock; } @Override public DBlock getDBlock(DBlock block, StorageGroup source) { if (block instanceof DBlockStriped) { return ((DBlockStriped) block).getInternalBlock(source); } return block; } @Override public DFSInputStream getNormalInputStream(DFSClient dfsClient, String src, boolean verifyChecksum, FileState fileState) throws IOException { LocatedBlocks locatedBlocks = dfsClient.getLocatedBlocks(src, 0); ErasureCodingPolicy ecPolicy = locatedBlocks.getErasureCodingPolicy(); if (ecPolicy != null) { return new SmartStripedInputStream(dfsClient, src, verifyChecksum, ecPolicy, locatedBlocks, fileState); } return new SmartInputStream(dfsClient, src, verifyChecksum, fileState); } }
java
Apache-2.0
e0c90f054687a18c4e095547ac5e31b8b313b3ef
2026-01-05T02:41:11.405497Z
false