@Override public List<UserRecord> findUsers(List<String> users) { List<UserRecord> userRecords = new ArrayList<>(); Set<String> userSet = new HashSet<>(users); // load config Ini ini = new Ini(); try (InputStream in = new FileInputStream(FileSystemManager.getConfig("shiro.ini"))) { ini.load(in); Section section = ini.getSection("users"); for (String user : section.keySet()) { if (userSet.contains(user)) { UserRecord userRecord = new UserRecord(); userRecord.setUsername(user); userRecords.add(userRecord); } } } catch (IOException ex) { throw new OpenStorefrontRuntimeException( "Unable to read shiro.ini file.", "Check config path and permissions", ex); } return userRecords; }
// Binder call @Override public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) { if (mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) { pw.println("Permission Denial: can't dump MediaRouterService from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); return; } pw.println("MEDIA ROUTER SERVICE (dumpsys media_router)"); pw.println(); pw.println("Global state"); pw.println(" mCurrentUserId=" + mCurrentUserId); synchronized (mLock) { final int count = mUserRecords.size(); for (int i = 0; i < count; i++) { UserRecord userRecord = mUserRecords.valueAt(i); pw.println(); userRecord.dump(pw, ""); } } }
public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof UserRecord)) return false; UserRecord other = (UserRecord) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc == obj); } __equalsCalc = obj; boolean _equals; _equals = true && ((this.id == null && other.getId() == null) || (this.id != null && this.id.equals(other.getId()))) && ((this.name == null && other.getName() == null) || (this.name != null && this.name.equals(other.getName()))) && ((this.email == null && other.getEmail() == null) || (this.email != null && this.email.equals(other.getEmail()))) && ((this.roleId == null && other.getRoleId() == null) || (this.roleId != null && this.roleId.equals(other.getRoleId()))) && ((this.roleName == null && other.getRoleName() == null) || (this.roleName != null && this.roleName.equals(other.getRoleName()))) && ((this.preferredLocale == null && other.getPreferredLocale() == null) || (this.preferredLocale != null && this.preferredLocale.equals(other.getPreferredLocale()))) && ((this.userRecordType == null && other.getUserRecordType() == null) || (this.userRecordType != null && this.userRecordType.equals(other.getUserRecordType()))); __equalsCalc = null; return _equals; }
/** * Do the main operation in emulate Mode: (1) Write a new URL Site Visit Record to the base DB (2) * Check to see if the corresponding User Record is in the Segmented Cache -- If not, write a new * User Record with the CACHE TTL -- UPDATE THE USER RECORD WITH A NEW (FULL) LDT Load (Scan the * existing LDT in the base DB and write to the cache LDT) (3) Probe the Base DB to see if the LDT * data is consistent. * * @param opNum */ private void doOperation(int opNum, ILdtOperations ldtOps) { final String meth = "doOperation()"; boolean recordPresent = false; String baseSet; String cacheSet; try { int customerSeed = random.nextInt(this.customerMax); CustomerRecord custRec = new CustomerRecord(console, customerSeed); long userSeed = getUserRecordSeed(this.userMax); UserRecord userRec = new UserRecord(console, dbOps, custRec.getCustomerID(), (int) userSeed); SiteVisitEntry sve = new SiteVisitEntry( console, custRec.getCustomerID(), userRec.getUserID(), opNum, LDT_BIN, this.timeToLive); baseSet = userRec.getCustomerBaseSet(); cacheSet = userRec.getCustomerCacheSet(); // Write the Site Visit to Storage -- which is hidden behind // this interface because there can be multiple implementations // of the LDT. sve.toStorage(client, baseNamespace, baseSet, ldtOps); // Check to see if the UserRecord is in the Segment Cache. If it is, // then add to the Cache LDT. If it is not, then create a new // User Record in the Segment, and populate the LDT Info (the Site // Visit Data) with the LDT data from the DB User Record. recordPresent = userRec.updateCache(client, cacheNamespace); if (recordPresent) { sve.toStorage(client, cacheNamespace, cacheSet, ldtOps); } else { sve.reloadCache(client, baseNamespace, cacheNamespace, ldtOps); } String keyStr = userRec.getUserID(); // At predetermined milestones, perform various actions // Show Simple Status at regular internals. For the regular large // scale tests with 100 threads, we won't hit this very often. if ((opNum + threadNumber) % 1000 == 0) { console.debug( "<%s:%s> Thread(%d) Cust#(%d) BaseSet(%s) User#(%d) UserID(%s) Iteration(%d)", CLASSNAME, meth, threadNumber, customerSeed, baseSet, userSeed, keyStr, opNum); } // Do a heavy duty scan less frequently. if ((opNum + threadNumber) % 2000 == 0) { Key baseKey = new Key(baseNamespace, baseSet, keyStr); Key cacheKey = new Key(cacheNamespace, cacheSet, keyStr); console.debug( "<%s:%s> <<SCAN TEST>> Thread(%d) Cust#(%d) BaseSet(%s) CacheSet(%s) User#(%d) UserID(%s) Iteration(%d)", CLASSNAME, meth, threadNumber, customerSeed, baseSet, cacheSet, userSeed, keyStr, opNum); List<Map<String, Object>> baseResult = null; List<Map<String, Object>> cacheResult = null; int baseResultSize = 0; int baseCheckSize = 0; int cacheResultSize = 0; int cacheCheckSize = 0; try { baseResult = ldtOps.scanLDT(baseKey); cacheResult = ldtOps.scanLDT(cacheKey); cacheCheckSize = ldtOps.ldtSize(cacheKey, LDT_BIN); if (baseResult != null) { baseResultSize = baseResult.size(); baseCheckSize = ldtOps.ldtSize(baseKey, LDT_BIN); if (baseResultSize != baseCheckSize) { console.error( "<%s:%s> <<BASE SCAN Size Error>> Thread(%d) Cust#(%d) BaseSet(%s) UserID(%s) ScanSide(%d) LDT Size(%d)", CLASSNAME, meth, threadNumber, customerSeed, baseSet, keyStr, baseResultSize, baseCheckSize); } } if (cacheResult != null) { cacheResultSize = cacheResult.size(); cacheCheckSize = ldtOps.ldtSize(cacheKey, LDT_BIN); if (cacheResultSize != cacheCheckSize) { console.error( "<%s:%s> <<CACHE SCAN Size Error>> Thread(%d) Cust#(%d) CacheSet(%s) UserID(%s) ScanSide(%d) LDT Size(%d)", CLASSNAME, meth, threadNumber, customerSeed, cacheSet, keyStr, cacheResultSize, cacheCheckSize); } } } catch (AerospikeException ae) { console.error( "Aerospike Error Code(%d) Error Message(%s)", ae.getResultCode(), ae.getMessage()); console.info("Keep on Truckin"); } console.debug( "<%s:%s> <<SCAN RESULT>> Thread(%d) Cust#(%d) BaseSet(%s) CacheSet(%s) UserID(%s) BaseLDT(%d) CacheLDT(%d)", CLASSNAME, meth, threadNumber, customerSeed, baseSet, cacheSet, keyStr, baseResultSize, cacheResultSize); } } catch (AerospikeException ae) { console.error( "Aerospike Error Code(%d) Error Message(%s)", ae.getResultCode(), ae.getMessage()); } catch (Exception e) { e.printStackTrace(); console.error( "[%s] Problem with Thread(%d) Customer Record: Seed(%d)", "Emulate: doOperation(): ", threadNumber, opNum); } }