proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/common/filter/AuthFilter.java | AuthFilter | doFilter | class AuthFilter implements Filter {
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
public void init(FilterConfig config) throws ServletException {
}
public void destroy() {
}
/**
* doFilter determines if user is an administrator or redirect to login page
... |
HttpServletRequest servletRequest = (HttpServletRequest) req;
HttpServletResponse servletResponse = (HttpServletResponse) resp;
boolean isAdmin = false;
try {
//read auth token
String authToken = AuthUtil.getAuthToken(servletRequest.getSession());
... | 159 | 566 | 725 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/common/util/AppConfig.java | AppConfig | decryptProperty | class AppConfig {
private static final Logger log = LoggerFactory.getLogger(AppConfig.class);
private static PropertiesConfiguration prop;
public static final String CONFIG_DIR = StringUtils.isNotEmpty(System.getProperty("CONFIG_DIR")) ? System.getProperty("CONFIG_DIR").trim() : AppConfig.class.getClassLoa... |
String retVal = prop.getString(name);
if (StringUtils.isNotEmpty(retVal)) {
retVal = retVal.replaceAll("^" + EncryptionUtil.CRYPT_ALGORITHM + "\\{", "").replaceAll("\\}$", "");
retVal = EncryptionUtil.decrypt(retVal);
}
return retVal;
| 1,308 | 97 | 1,405 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/common/util/AuthUtil.java | AuthUtil | getAuthToken | class AuthUtil {
public static final String SESSION_ID = "sessionId";
public static final String USER_ID = "userId";
public static final String USERNAME = "username";
public static final String AUTH_TOKEN = "authToken";
public static final String TIMEOUT = "timeout";
private AuthUtil() {
}... |
String authToken = (String) session.getAttribute(AUTH_TOKEN);
authToken = EncryptionUtil.decrypt(authToken);
return authToken;
| 1,815 | 45 | 1,860 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/LoginKtrl.java | LoginKtrl | loginSubmit | class LoginKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(LoginKtrl.class);
//check if otp is enabled
@Model(name = "otpEnabled")
static final Boolean otpEnabled = ("required".equals(AppConfig.getProperty("oneTimePassword")) || "optional".equals(AppConfig... |
String retVal = "redirect:/admin/menu.html";
String authToken = null;
try {
authToken = AuthDB.login(auth);
//get client IP
String clientIP = AuthUtil.getClientIPAddress(getRequest());
if (authToken != null) {
User us... | 572 | 868 | 1,440 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/OTPKtrl.java | OTPKtrl | qrImage | class OTPKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(OTPKtrl.class);
public static final boolean requireOTP = "required".equals(AppConfig.getProperty("oneTimePassword"));
//QR image size
private static final int QR_IMAGE_WIDTH = 325;
private sta... |
String username;
String secret;
try {
username = UserDB.getUser(AuthUtil.getUserId(getRequest().getSession())).getUsername();
secret = AuthUtil.getOTPSecret(getRequest().getSession());
AuthUtil.setOTPSecret(getRequest().getSession(), null);
}... | 592 | 675 | 1,267 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/ProfileKtrl.java | ProfileKtrl | saveProfile | class ProfileKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(ProfileKtrl.class);
@Model(name = "sortedSet")
SortedSet sortedSet = new SortedSet();
@Model(name = "profile")
Profile profile = new Profile();
public ProfileKtrl(HttpServletRequest r... |
try {
if (profile.getId() != null) {
ProfileDB.updateProfile(profile);
} else {
ProfileDB.insertProfile(profile);
}
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toString(), ex);
... | 693 | 161 | 854 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/ProfileSystemsKtrl.java | ProfileSystemsKtrl | viewProfileSystems | class ProfileSystemsKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(ProfileSystemsKtrl.class);
@Model(name = "profile")
Profile profile;
@Model(name = "sortedSet")
SortedSet sortedSet = new SortedSet();
@Model(name = "systemSelectId")
List<Long> syst... |
if (profile != null && profile.getId() != null) {
try {
profile = ProfileDB.getProfile(profile.getId());
sortedSet = SystemDB.getSystemSet(sortedSet, profile.getId());
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toS... | 361 | 122 | 483 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/ProfileUsersKtrl.java | ProfileUsersKtrl | assignSystemsToProfile | class ProfileUsersKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(ProfileUsersKtrl.class);
@Model(name = "profile")
Profile profile;
@Model(name = "sortedSet")
SortedSet sortedSet = new SortedSet();
@Model(name = "userSelectId")
List<Long> userSelect... |
if (userSelectId != null) {
try {
UserProfileDB.setUsersForProfile(profile.getId(), userSelectId);
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toString(), ex);
throw new ServletException(ex.toString(), ex);
... | 351 | 120 | 471 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/ScriptKtrl.java | ScriptKtrl | validateSaveScript | class ScriptKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(ScriptKtrl.class);
@Model(name = "sortedSet")
SortedSet sortedSet = new SortedSet();
@Model(name = "script")
Script script = new Script();
public ScriptKtrl(HttpServletRequest request, HttpServ... |
if (script == null
|| script.getDisplayNm() == null
|| script.getDisplayNm().trim().equals("")) {
addFieldError("script.displayNm", "Required");
}
if (script == null
|| script.getScript() == null
|| script.getScript().... | 707 | 227 | 934 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/SessionAuditKtrl.java | SessionAuditKtrl | getJSONTermOutputForSession | class SessionAuditKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(SessionAuditKtrl.class);
@Model(name = "sortedSet")
SortedSet sortedSet = new SortedSet();
@Model(name = "sessionId")
Long sessionId;
@Model(name = "instanceId")
Integer instanceId;
... |
try {
String json = new Gson().toJson(SessionAuditDB.getTerminalLogsForSession(sessionId, instanceId));
getResponse().getOutputStream().write(json.getBytes());
} catch (SQLException | GeneralSecurityException | IOException ex) {
log.error(ex.toString(), ex);
... | 644 | 106 | 750 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/SystemKtrl.java | SystemKtrl | validateSaveSystem | class SystemKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(SystemKtrl.class);
public static final String REQUIRED = "Required";
@Model(name = "sortedSet")
SortedSet sortedSet = new SortedSet();
@Model(name = "hostSystem")
HostSystem hostSystem =... |
if (hostSystem == null
|| hostSystem.getDisplayNm() == null
|| hostSystem.getDisplayNm().trim().equals("")) {
addFieldError("hostSystem.displayNm", REQUIRED);
}
if (hostSystem == null
|| hostSystem.getUser() == null
... | 1,208 | 432 | 1,640 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/UploadAndPushKtrl.java | UploadAndPushKtrl | push | class UploadAndPushKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(UploadAndPushKtrl.class);
public static final String UPLOAD_PATH = DBUtils.class.getClassLoader().getResource(".").getPath() + "../upload";
@Model(name = "upload")
File upload;
@Model(name = ... |
try {
Long userId = AuthUtil.getUserId(getRequest().getSession());
Long sessionId = AuthUtil.getSessionId(getRequest().getSession());
//get next pending system
pendingSystemStatus = SystemStatusDB.getNextPendingSystem(userId);
if (pendingSystemStat... | 750 | 689 | 1,439 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/UserSettingsKtrl.java | UserSettingsKtrl | passwordSubmit | class UserSettingsKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(UserSettingsKtrl.class);
public static final String REQUIRED = "Required";
@Model(name = "themeMap")
static Map<String, String> themeMap1 = new LinkedHashMap<>(Map.ofEntries(
en... |
String retVal = "/admin/user_settings.html";
if (!auth.getPassword().equals(auth.getPasswordConfirm())) {
addError("Passwords do not match");
} else if (!PasswordUtil.isValid(auth.getPassword())) {
addError(PasswordUtil.PASSWORD_REQ_ERROR_MSG);
} else... | 1,212 | 245 | 1,457 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/control/UsersKtrl.java | UsersKtrl | validateSaveUser | class UsersKtrl extends BaseKontroller {
private static final Logger log = LoggerFactory.getLogger(UsersKtrl.class);
public static final String REQUIRED = "Required";
@Model(name = "sortedSet")
SortedSet sortedSet = new SortedSet();
@Model(name = "user")
User user = new User();
@M... |
if (user == null
|| user.getUsername() == null
|| user.getUsername().trim().equals("")) {
addFieldError("user.username", REQUIRED);
}
if (user == null
|| user.getLastNm() == null
|| user.getLastNm().trim().equ... | 1,133 | 528 | 1,661 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/db/PrivateKeyDB.java | PrivateKeyDB | getApplicationKey | class PrivateKeyDB {
private PrivateKeyDB() {
}
/**
* returns public private key for application
*
* @return app key values
*/
public static ApplicationKey getApplicationKey() throws SQLException, GeneralSecurityException {<FILL_FUNCTION_BODY>}
} |
ApplicationKey appKey = null;
Connection con = DBUtils.getConn();
PreparedStatement stmt = con.prepareStatement("select * from application_key");
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
appKey = new ApplicationKey();
appKey.setId(rs... | 77 | 207 | 284 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/db/ProfileDB.java | ProfileDB | getProfileSet | class ProfileDB {
public static final String FILTER_BY_SYSTEM = "system";
public static final String FILTER_BY_USER = "username";
public static final String SORT_BY_PROFILE_NM = "nm";
private ProfileDB() {
}
/**
* method to do order by based on the sorted set object for profiles
*
... |
ArrayList<Profile> profileList = new ArrayList<>();
String orderBy = "";
if (sortedSet.getOrderByField() != null && !sortedSet.getOrderByField().trim().equals("")) {
orderBy = " order by " + sortedSet.getOrderByField() + " " + sortedSet.getOrderByDirection();
}
Str... | 1,136 | 785 | 1,921 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/db/ProfileSystemsDB.java | ProfileSystemsDB | getSystemIdsByProfile | class ProfileSystemsDB {
private ProfileSystemsDB() {
}
/**
* sets host systems for profile
*
* @param profileId profile id
* @param systemIdList list of host system ids
*/
public static void setSystemsForProfile(Long profileId, List<Long> systemIdList) throws SQLException,... |
List<Long> systemIdList = new ArrayList<>();
PreparedStatement stmt = con.prepareStatement("select * from system s, system_map m where s.id=m.system_id and m.profile_id=? order by display_nm asc");
stmt.setLong(1, profileId);
ResultSet rs = stmt.executeQuery();
while (rs.next... | 1,344 | 151 | 1,495 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/db/ScriptDB.java | ScriptDB | getScript | class ScriptDB {
public static final String DISPLAY_NM = "display_nm";
public static final String SORT_BY_DISPLAY_NM = DISPLAY_NM;
private ScriptDB() {
}
/**
* returns scripts based on sort order defined
*
* @param sortedSet object that defines sort order
* @param userId u... |
Script script = null;
PreparedStatement stmt = con.prepareStatement("select * from scripts where id=? and user_id=?");
stmt.setLong(1, scriptId);
stmt.setLong(2, userId);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
script = new Script();
... | 1,177 | 175 | 1,352 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/db/SystemStatusDB.java | SystemStatusDB | getNextPendingSystem | class SystemStatusDB {
public static final String STATUS_CD = "status_cd";
private SystemStatusDB() {
}
/**
* set the initial status for selected systems
*
* @param systemSelectIds systems ids to set initial status
* @param userId user id
* @param userType use... |
HostSystem hostSystem = null;
Connection con = DBUtils.getConn();
PreparedStatement stmt = con.prepareStatement("select * from status where (status_cd like ? or status_cd like ? or status_cd like ?) and user_id=? order by id asc");
stmt.setString(1, HostSystem.INITIAL_STATUS);
... | 1,683 | 255 | 1,938 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/db/UserProfileDB.java | UserProfileDB | checkIsUsersProfile | class UserProfileDB {
private UserProfileDB() {
}
/**
* sets users for profile
*
* @param profileId profile id
* @param userIdList list of user ids
*/
public static void setUsersForProfile(Long profileId, List<Long> userIdList) throws SQLException, GeneralSecurityException {
... |
boolean isUsersProfile = false;
Connection con = DBUtils.getConn();
PreparedStatement stmt = con.prepareStatement("select * from user_map where profile_id=? and user_id=?");
stmt.setLong(1, profileId);
stmt.setLong(2, userId);
ResultSet rs = stmt.executeQuery();
... | 1,593 | 159 | 1,752 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/db/UserThemeDB.java | UserThemeDB | getTheme | class UserThemeDB {
private UserThemeDB() {
}
/**
* get user theme
*
* @param userId object
* @return user theme object
*/
public static UserSettings getTheme(Long userId) throws SQLException, GeneralSecurityException {<FILL_FUNCTION_BODY>}
/**
* saves user theme
... |
UserSettings theme = null;
Connection con = DBUtils.getConn();
PreparedStatement stmt = con.prepareStatement("select * from user_theme where user_id=?");
stmt.setLong(1, userId);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
theme = new UserSettings(... | 541 | 456 | 997 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/model/SortedSet.java | SortedSet | getOrderByField | class SortedSet {
private String orderByField = null;
private String orderByDirection = "asc";
private List itemList;
private Map<String, String> filterMap = new HashMap<>();
public SortedSet() {
}
public SortedSet(String orderByField) {
this.orderByField = orderByField;
}
... |
if (orderByField != null) {
return orderByField.replaceAll("[^0-9,a-z,A-Z,\\_,\\.]", "");
}
return null;
| 334 | 55 | 389 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/model/UserSettings.java | UserSettings | setPlane | class UserSettings {
String[] colors = null;
String bg;
String fg;
String plane;
String theme;
Integer ptyWidth;
Integer ptyHeight;
public String[] getColors() {
return colors;
}
public void setColors(String[] colors) {
this.colors = colors;
}
public S... |
if (StringUtils.isNotEmpty(plane) && plane.split(",").length == 2) {
this.setBg(plane.split(",")[0]);
this.setFg(plane.split(",")[1]);
}
this.plane = plane;
| 494 | 73 | 567 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/task/SecureShellTask.java | SecureShellTask | run | class SecureShellTask implements Runnable {
private static final Logger log = LoggerFactory.getLogger(SecureShellTask.class);
InputStream outFromChannel;
SessionOutput sessionOutput;
public SecureShellTask(SessionOutput sessionOutput, InputStream outFromChannel) {
this.sessionOutput = sessio... |
InputStreamReader isr = new InputStreamReader(outFromChannel);
BufferedReader br = new BufferedReader(isr);
SessionOutputUtil.addOutput(sessionOutput);
char[] buff = new char[1024];
int read;
try {
while ((read = br.read(buff)) != -1) {
Sess... | 121 | 183 | 304 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/task/SentOutputTask.java | SentOutputTask | run | class SentOutputTask implements Runnable {
private static final Logger log = LoggerFactory.getLogger(SentOutputTask.class);
Session session;
Long sessionId;
User user;
public SentOutputTask(Long sessionId, Session session, User user) {
this.sessionId = sessionId;
this.session = se... |
Gson gson = new Gson();
while (session.isOpen()) {
try {
Connection con = DBUtils.getConn();
List<SessionOutput> outputList = SessionOutputUtil.getOutput(con, sessionId, user);
if (!outputList.isEmpty()) {
String json = gso... | 120 | 171 | 291 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/util/DSPool.java | DSPool | registerDataSource | class DSPool {
private static BasicDataSource dsPool = null;
private static final String BASE_DIR = AppConfig.CONFIG_DIR;
private static final String DB_DRIVER = AppConfig.getProperty("dbDriver");
private static final int MAX_ACTIVE = Integer.parseInt(AppConfig.getProperty("maxActive"));
private s... |
System.setProperty("h2.baseDir", BASE_DIR);
// create a database connection
String user = AppConfig.getProperty("dbUser");
String password = AppConfig.decryptProperty("dbPassword");
String connectionURL = AppConfig.getProperty("dbConnectionURL");
if (connectionURL != n... | 320 | 269 | 589 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/util/EncryptionUtil.java | EncryptionUtil | encrypt | class EncryptionUtil {
private static final Logger log = LoggerFactory.getLogger(EncryptionUtil.class);
//secret key
private static byte[] key = new byte[0];
static {
try {
key = KeyStoreUtil.getSecretBytes(KeyStoreUtil.ENCRYPTION_KEY_ALIAS);
} catch (GeneralSecurityExcept... |
String retVal = null;
if (str != null && str.length() > 0) {
Cipher c = Cipher.getInstance(CRYPT_ALGORITHM);
c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, CRYPT_ALGORITHM));
byte[] encVal = c.doFinal(str.getBytes());
retVal = new String(Base64.encod... | 912 | 131 | 1,043 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/util/KeyStoreUtil.java | KeyStoreUtil | initializeKeyStore | class KeyStoreUtil {
private static final Logger log = LoggerFactory.getLogger(KeyStoreUtil.class);
private static KeyStore keyStore = null;
private static final String keyStoreFile = AppConfig.CONFIG_DIR
+ "/bastillion.jceks";
private static final char[] KEYSTORE_PASS = new char[]{
... |
keyStore = KeyStore.getInstance("JCEKS");
//create keystore
keyStore.load(null, KEYSTORE_PASS);
//set encryption key
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(KEYLENGTH);
KeyStoreUtil.setSecret(KeyStoreUtil.ENCRYPTION_KEY_ALI... | 1,649 | 152 | 1,801 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/util/OTPUtil.java | OTPUtil | verifyToken | class OTPUtil {
private static final Logger log = LoggerFactory.getLogger(OTPUtil.class);
//sizes to generate OTP secret
private static final int SECRET_SIZE = 10;
private static final int NUM_SCRATCH_CODES = 5;
private static final int SCRATCH_CODE_SIZE = 4;
//token window in near future or ... |
long calculated = -1;
byte[] key = new Base32().decode(secret);
SecretKeySpec secretKey = new SecretKeySpec(key, "HmacSHA1");
try {
Mac mac = Mac.getInstance("HmacSHA1");
mac.init(secretKey);
byte[] hash = mac.doFinal(ByteBuffer.allocate(8).putLon... | 540 | 240 | 780 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/util/RefreshAuthKeyUtil.java | RefreshAllSystemsTask | run | class RefreshAllSystemsTask implements Runnable {
private static final Logger log = LoggerFactory.getLogger(RefreshAllSystemsTask.class);
@Override
public void run() {<FILL_FUNCTION_BODY>}
} |
//distribute all public keys
try {
SSHUtil.distributePubKeysToAllSystems();
} catch (SQLException | GeneralSecurityException ex) {
log.error(ex.toString(), ex);
}
| 65 | 59 | 124 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/util/SessionOutputSerializer.java | SessionOutputSerializer | serialize | class SessionOutputSerializer implements JsonSerializer<Object> {
@Override
public JsonElement serialize(Object src, Type typeOfSrc, JsonSerializationContext context) {<FILL_FUNCTION_BODY>}
} |
JsonObject object = new JsonObject();
if (typeOfSrc.equals(AuditWrapper.class)) {
AuditWrapper auditWrapper = (AuditWrapper) src;
object.addProperty("user_id", auditWrapper.getUser().getId());
object.addProperty("username", auditWrapper.getUser().getUsername());
... | 54 | 296 | 350 | <no_super_class> |
bastillion-io_Bastillion | Bastillion/src/main/java/io/bastillion/manage/util/SessionOutputUtil.java | SessionOutputUtil | getOutput | class SessionOutputUtil {
private static final Map<Long, UserSessionsOutput> userSessionsOutputMap = new ConcurrentHashMap<>();
public final static boolean enableInternalAudit = "true".equals(AppConfig.getProperty("enableInternalAudit"));
private static final Gson gson = new GsonBuilder().registerTypeAdapt... |
List<SessionOutput> outputList = new ArrayList<>();
UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(sessionId);
if (userSessionsOutput != null) {
for (Integer key : userSessionsOutput.getSessionOutputMap().keySet()) {
//get output chars and set t... | 787 | 267 | 1,054 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashCloseOnExitHook.java | ChronicleHashCloseOnExitHook | closeAll | class ChronicleHashCloseOnExitHook {
private static WeakHashMap<VanillaChronicleHash<?, ?, ?, ?>.Identity, Long> maps = new WeakHashMap<>();
private static long order = 0;
static {
PriorityHook.add(80, ChronicleHashCloseOnExitHook::closeAll);
}
private ChronicleHashCloseOnExitHook() {
... |
try {
WeakHashMap<VanillaChronicleHash<?, ?, ?, ?>.Identity, Long> maps;
synchronized (ChronicleHashCloseOnExitHook.class) {
maps = ChronicleHashCloseOnExitHook.maps;
ChronicleHashCloseOnExitHook.maps = null;
}
TreeMap<Long, Vanil... | 250 | 541 | 791 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/InMemoryChronicleHashResources.java | InMemoryChronicleHashResources | releaseMemoryResource | class InMemoryChronicleHashResources extends ChronicleHashResources {
@Override
void releaseMemoryResource(final MemoryResource allocation) {<FILL_FUNCTION_BODY>}
} |
assert SKIP_ASSERTIONS || assertAddress(allocation.address);
assert SKIP_ASSERTIONS || assertPosition(allocation.size);
OS.memory().freeMemory(allocation.address, allocation.size);
| 46 | 57 | 103 | <methods>public non-sealed void <init>() ,public final boolean releaseManually() ,public void run() ,public final void setChronicleHashIdentityString(java.lang.String) <variables>private static final int COMPLETELY_CLOSED,private static final int OPEN,private static final int PARTIALLY_CLOSED,private java.lang.String c... |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/IntCompactOffHeapLinearHashTable.java | IntCompactOffHeapLinearHashTable | writeEntryVolatile | class IntCompactOffHeapLinearHashTable extends CompactOffHeapLinearHashTable {
private static final long SCALE = 4L;
/**
* Must not store {@code h} in a field, to avoid memory leaks.
*
* @see net.openhft.chronicle.hash.impl.stage.hash.Chaining#initMap
*/
IntCompactOffHeapLinearHashTabl... |
assert SKIP_ASSERTIONS || assertAddress(address);
assert SKIP_ASSERTIONS || assertPosition(pos);
OS.memory().writeVolatileInt(address + pos, (int) entry(key, value));
| 557 | 57 | 614 | <methods>public static long capacityFor(long) ,public void checkValueForPut(long) ,public abstract void clearEntry(long, long) ,public boolean empty(long) ,public long entry(long, long) ,public static int entrySize(int, int) ,public long hlPos(long) ,public long key(long) ,public static int keyBits(long, int) ,public s... |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/LongCompactOffHeapLinearHashTable.java | LongCompactOffHeapLinearHashTable | clearEntry | class LongCompactOffHeapLinearHashTable extends CompactOffHeapLinearHashTable {
private static final long SCALE = 8L;
/**
* Must not store {@code h} in a field, to avoid memory leaks.
*
* @see net.openhft.chronicle.hash.impl.stage.hash.Chaining#initMap
*/
LongCompactOffHeapLinearHashTa... |
assert SKIP_ASSERTIONS || assertAddress(address);
assert SKIP_ASSERTIONS || assertPosition(pos);
OS.memory().writeLong(address + pos, 0L);
| 570 | 50 | 620 | <methods>public static long capacityFor(long) ,public void checkValueForPut(long) ,public abstract void clearEntry(long, long) ,public boolean empty(long) ,public long entry(long, long) ,public static int entrySize(int, int) ,public long hlPos(long) ,public long key(long) ,public static int keyBits(long, int) ,public s... |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/PersistedChronicleHashResources.java | PersistedChronicleHashResources | releaseExtraSystemResources | class PersistedChronicleHashResources extends ChronicleHashResources {
private File file;
public PersistedChronicleHashResources(File file) {
this.file = file;
OS.memory().storeFence(); // Emulate final semantics of the file field
}
@Override
void releaseMemoryResource(MemoryResou... |
if (file == null)
return null;
Throwable thrown = null;
try {
CanonicalRandomAccessFiles.release(file);
file = null;
} catch (Throwable t) {
thrown = t;
}
return thrown;
| 136 | 71 | 207 | <methods>public non-sealed void <init>() ,public final boolean releaseManually() ,public void run() ,public final void setChronicleHashIdentityString(java.lang.String) <variables>private static final int COMPLETELY_CLOSED,private static final int OPEN,private static final int PARTIALLY_CLOSED,private java.lang.String c... |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/data/bytes/EntryKeyBytesData.java | EntryKeyBytesData | innerGetUsing | class EntryKeyBytesData<K> extends AbstractData<K> {
@StageRef
VanillaChronicleHashHolder<K> hh;
@StageRef
KeyBytesInterop<K> ki;
@StageRef
SegmentStages s;
@StageRef
HashEntryStages<K> entry;
@StageRef
CheckOnEachPublicOperation checkOnEachPublicOperation;
@Stage("CachedEn... |
Bytes bytes = s.segmentBytesForRead();
bytes.readPosition(entry.keyOffset);
return ki.keyReader.read(bytes, size(), usingKey);
| 450 | 47 | 497 | <methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/data/bytes/InputKeyBytesData.java | InputKeyBytesData | initInputKeyBytesStore | class InputKeyBytesData<K> extends AbstractData<K> {
@Stage("InputKeyBytes")
private final VanillaBytes inputKeyBytes = VanillaBytes.vanillaBytes();;
@StageRef
KeyBytesInterop<K> ki;
@StageRef
CheckOnEachPublicOperation checkOnEachPublicOperation;
@Stage("InputKeyBytesStore")
private By... |
inputKeyBytesStore = bytesStore;
inputKeyBytesOffset = offset;
inputKeyBytesSize = size;
| 642 | 31 | 673 | <methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public java.lang.String toString() <variables> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/AllocatedChunks.java | AllocatedChunks | initEntryAndKeyCopying | class AllocatedChunks {
@StageRef
public VanillaChronicleHashHolder<?> hh;
@StageRef
public SegmentStages s;
@StageRef
public HashEntryStages<?> entry;
@StageRef
public Alloc alloc;
public int allocatedChunks = 0;
public void initAllocatedChunks(int allocatedChunks) {
... |
initAllocatedChunks(hh.h().inChunks(entrySize));
long oldSegmentTierBaseAddr = s.tierBaseAddr;
long oldKeySizeAddr = oldSegmentTierBaseAddr + entry.keySizeOffset;
long oldKeyAddr = oldSegmentTierBaseAddr + entry.keyOffset;
int tierBeforeAllocation = s.tier;
long pos = al... | 188 | 153 | 341 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashEntryChecksumStrategy.java | HashEntryChecksumStrategy | computeChecksum | class HashEntryChecksumStrategy implements ChecksumStrategy {
@StageRef
SegmentStages s;
@StageRef
HashEntryStages<?> e;
@StageRef
KeyHashCode h;
@Override
public void computeAndStoreChecksum() {
int checksum = computeChecksum();
s.segmentBS.writeInt(e.entryEnd(), check... |
long keyHashCode = h.keyHashCode();
long keyEnd = e.keyEnd();
long len = e.entryEnd() - keyEnd;
long checksum;
if (len > 0) {
long addr = s.tierBaseAddr + keyEnd;
long payloadChecksum = LongHashFunction.xx_r39().hashMemory(addr, len);
checks... | 257 | 173 | 430 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashEntryStages.java | HashEntryStages | checkSum | class HashEntryStages<K> implements HashEntry<K>, ChecksumEntry {
@StageRef
public VanillaChronicleHashHolder<?> hh;
@StageRef
public SegmentStages s;
@StageRef
public CheckOnEachPublicOperation checkOnEachPublicOperation;
@StageRef
public HashLookupPos hlp;
public long pos = -1;
... |
checkOnEachPublicOperation.checkOnEachPublicOperation();
if (!hh.h().checksumEntries) {
throw new UnsupportedOperationException(hh.h().toIdentityString() +
": Checksum is not stored in this Chronicle Hash");
}
// This is needed, because a concurrent updat... | 1,527 | 158 | 1,685 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashLookupPos.java | HashLookupPos | initHashLookupPos | class HashLookupPos {
public long hashLookupPos = -1;
@StageRef
HashLookupSearch hls;
@StageRef
SegmentStages s;
public abstract boolean hashLookupPosInit();
public void initHashLookupPos() {<FILL_FUNCTION_BODY>}
public void initHashLookupPos(long hashLookupPos) {
this.hashLo... |
// Validation + make hashLookupPos a dependant of tier. This is needed, because after
// tier change should re-perform hashLookupSearch, starting from the searchStartPos.
// Not an assert statement, because segmentTier stage should be initialized regardless
// assertions enabled or not.... | 180 | 121 | 301 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/HashLookupSearch.java | HashLookupSearch | nextPos | class HashLookupSearch {
@StageRef
public VanillaChronicleHashHolder<?> hh;
@Stage("SearchKey")
public long searchStartPos;
@StageRef
SegmentStages s;
@StageRef
HashLookupPos hlp;
@StageRef
KeySearch<?> ks;
@StageRef
MapEntryStages<?, ?> e;
@Stage("SearchKey")
lo... |
long pos = hlp.hashLookupPos;
CompactOffHeapLinearHashTable hl = hl();
while (true) {
// read volatile to make a happens-before edge between entry insertion from concurrent
// thread under update lock and this thread (reading the entry)
long entry = hl.readEn... | 618 | 222 | 840 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/ReadLock.java | ReadLock | unlock | class ReadLock implements InterProcessLock {
@StageRef
CheckOnEachPublicOperation checkOnEachPublicOperation;
@StageRef
SegmentStages s;
@StageRef
HashEntryStages entry;
@StageRef
HashLookupPos hlp;
@Override
public boolean isHeldByCurrentThread() {
checkOnEachPublicOpe... |
checkOnEachPublicOperation.checkOnEachLockOperation();
if (s.localLockState != UNLOCKED) {
// TODO what should close here?
hlp.closeHashLookupPos();
entry.closeEntry();
}
s.readUnlockAndDecrementCount();
s.setLocalLockState(UNLOCKED);
| 825 | 89 | 914 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/UpdateLock.java | UpdateLock | unlock | class UpdateLock implements InterProcessLock {
@StageRef
VanillaChronicleHashHolder<?> hh;
@StageRef
CheckOnEachPublicOperation checkOnEachPublicOperation;
@StageRef
SegmentStages s;
@StageRef
HashEntryStages<?> entry;
@Override
public boolean isHeldByCurrentThread() {
... |
checkOnEachPublicOperation.checkOnEachLockOperation();
switch (s.localLockState) {
case UNLOCKED:
case READ_LOCKED:
return;
case UPDATE_LOCKED:
entry.closeDelayedUpdateChecksum();
if (s.decrementUpdate() == 0 && s.write... | 1,445 | 242 | 1,687 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/hash/Chaining.java | Chaining | initUsed | class Chaining extends ChainingInterface {
public final List<ChainingInterface> contextChain;
public final int indexInContextChain;
/**
* First context, ever created in this thread. rootContextInThisThread === contextChain.get(0).
*/
public final ChainingInterface rootContextInThisThread;
... |
assert used;
firstContextLockedInThisThread = rootContextInThisThread.lockContextLocally(map);
initMap(map);
this.used = true;
| 1,304 | 46 | 1,350 | <methods>public non-sealed void <init>() ,public abstract T getContext(Class<? extends T>, BiFunction<net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface,VanillaChronicleMap#RAW,T>, VanillaChronicleMap#RAW) ,public abstract List<net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface> getContextChain() ,p... |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/hash/OwnerThreadHolder.java | OwnerThreadHolder | checkAccessingFromOwnerThread | class OwnerThreadHolder {
final Thread owner = Thread.currentThread();
@StageRef
VanillaChronicleHashHolder<?> hh;
public void checkAccessingFromOwnerThread() {<FILL_FUNCTION_BODY>}
} |
if (owner != Thread.currentThread()) {
throw new ConcurrentModificationException(hh.h().toIdentityString() +
": Context shouldn't be accessed from multiple threads");
}
| 67 | 52 | 119 | <no_super_class> |
OpenHFT_Chronicle-Map | Chronicle-Map/src/main/java/net/openhft/chronicle/hash/impl/stage/hash/ThreadLocalState.java | ThreadLocalState | closeContext | class ThreadLocalState {
private static final Memory MEMORY = OS.memory();
private static final long CONTEXT_LOCK_OFFSET;
private static final int CONTEXT_UNLOCKED = 0;
private static final int CONTEXT_LOCKED_LOCALLY = 1;
private static final int CONTEXT_CLOSED = 2;
static {
try {
... |
if (tryCloseContext())
return;
// Unless there are bugs in this codebase, it could happen that
// contextLock == CONTEXT_CLOSED here only if closeContext() has succeed, and the subsequent
// contextHolder.clear() has failed in ChronicleHashResources.closeContext(), though th... | 912 | 923 | 1,835 | <no_super_class> |
End of preview. Expand in Data Studio
No dataset card yet
- Downloads last month
- 3