test_class.declarator: repository
test_class.modifier: private
test_class.original_string: private CassandraArchiveRepository repository;
test_class.type: CassandraArchiveRepository
test_class.var_name: repository
test_class.declarator: testArchiveJarFile
test_class.modifier: private
test_class.original_string: private Path testArchiveJarFile;
test_class.type: Path
test_class.var_name: testArchiveJarFile
test_class.declarator: gateway
test_class.modifier: private
test_class.original_string: private CassandraGateway gateway;
test_class.type: CassandraGateway
test_class.var_name: gateway
test_class.declarator: config
test_class.modifier: private
test_class.original_string: private CassandraArchiveRepositoryConfig config;
test_class.type: CassandraArchiveRepositoryConfig
test_class.var_name: config
test_class.file: nicobar-cassandra/src/test/java/com/netflix/nicobar/cassandra/CassandraArchiveRepositoryTest.java
test_class.identifier: CassandraArchiveRepositoryTest
test_case.body: @Test
      public void testGetScriptArchives() {
          // TODO: Fill out test.
      }
test_case.class_method_signature: CassandraArchiveRepositoryTest.testGetScriptArchives()
test_case.full_signature: @Test public void testGetScriptArchives()
test_case.identifier: testGetScriptArchives
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetScriptArchives()
focal_class.declarator: logger = LoggerFactory.getLogger(CassandraArchiveRepository.class)
focal_class.modifier: private final static
focal_class.original_string: private final static Logger logger = LoggerFactory.getLogger(CassandraArchiveRepository.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: defaultView
focal_class.modifier: protected final
focal_class.original_string: protected final RepositoryView defaultView;
focal_class.type: RepositoryView
focal_class.var_name: defaultView
focal_class.declarator: config
focal_class.modifier: private final
focal_class.original_string: private final CassandraArchiveRepositoryConfig config;
focal_class.type: CassandraArchiveRepositoryConfig
focal_class.var_name: config
focal_class.declarator: cassandra
focal_class.modifier: private final
focal_class.original_string: private final CassandraGateway cassandra;
focal_class.type: CassandraGateway
focal_class.var_name: cassandra
focal_class.file: nicobar-cassandra/src/main/java/com/netflix/nicobar/cassandra/CassandraArchiveRepository.java
focal_class.identifier: CassandraArchiveRepository
focal_class.interfaces: implements ArchiveRepository
focal_class.class_method_signature: CassandraArchiveRepository.CassandraArchiveRepository(CassandraArchiveRepositoryConfig config)
focal_class.full_signature: public  CassandraArchiveRepository(CassandraArchiveRepositoryConfig config)
focal_class.identifier: CassandraArchiveRepository
focal_class.modifiers: public
focal_class.parameters: (CassandraArchiveRepositoryConfig config)
focal_class.signature:  CassandraArchiveRepository(CassandraArchiveRepositoryConfig config)
focal_class.class_method_signature: CassandraArchiveRepository.CassandraArchiveRepository(CassandraArchiveRepositoryConfig config, RepositoryView defaultView)
focal_class.full_signature: public  CassandraArchiveRepository(CassandraArchiveRepositoryConfig config, RepositoryView defaultView)
focal_class.identifier: CassandraArchiveRepository
focal_class.modifiers: public
focal_class.parameters: (CassandraArchiveRepositoryConfig config, RepositoryView defaultView)
focal_class.signature:  CassandraArchiveRepository(CassandraArchiveRepositoryConfig config, RepositoryView defaultView)
focal_class.class_method_signature: CassandraArchiveRepository.getRepositoryId()
focal_class.full_signature: @Override public String getRepositoryId()
focal_class.identifier: getRepositoryId
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getRepositoryId()
focal_class.class_method_signature: CassandraArchiveRepository.getDefaultView()
focal_class.full_signature: @Override public RepositoryView getDefaultView()
focal_class.identifier: getDefaultView
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: RepositoryView
focal_class.signature: RepositoryView getDefaultView()
focal_class.class_method_signature: CassandraArchiveRepository.getView(String view)
focal_class.full_signature: @Override public RepositoryView getView(String view)
focal_class.identifier: getView
focal_class.modifiers: @Override public
focal_class.parameters: (String view)
focal_class.return: RepositoryView
focal_class.signature: RepositoryView getView(String view)
focal_class.class_method_signature: CassandraArchiveRepository.insertArchive(JarScriptArchive jarScriptArchive)
focal_class.full_signature: @Override public void insertArchive(JarScriptArchive jarScriptArchive)
focal_class.identifier: insertArchive
focal_class.modifiers: @Override public
focal_class.parameters: (JarScriptArchive jarScriptArchive)
focal_class.return: void
focal_class.signature: void insertArchive(JarScriptArchive jarScriptArchive)
focal_class.class_method_signature: CassandraArchiveRepository.insertArchive(JarScriptArchive jarScriptArchive, Map<String, Object> initialDeploySpecs)
focal_class.full_signature: @Override public void insertArchive(JarScriptArchive jarScriptArchive, Map<String, Object> initialDeploySpecs)
focal_class.identifier: insertArchive
focal_class.modifiers: @Override public
focal_class.parameters: (JarScriptArchive jarScriptArchive, Map<String, Object> initialDeploySpecs)
focal_class.return: void
focal_class.signature: void insertArchive(JarScriptArchive jarScriptArchive, Map<String, Object> initialDeploySpecs)
focal_class.class_method_signature: CassandraArchiveRepository.getScriptArchives(Set<ModuleId> moduleIds)
focal_class.full_signature: @Override public Set<ScriptArchive> getScriptArchives(Set<ModuleId> moduleIds)
focal_class.identifier: getScriptArchives
focal_class.modifiers: @Override public
focal_class.parameters: (Set<ModuleId> moduleIds)
focal_class.return: Set<ScriptArchive>
focal_class.signature: Set<ScriptArchive> getScriptArchives(Set<ModuleId> moduleIds)
focal_class.class_method_signature: CassandraArchiveRepository.deleteArchive(ModuleId moduleId)
focal_class.full_signature: @Override public void deleteArchive(ModuleId moduleId)
focal_class.identifier: deleteArchive
focal_class.modifiers: @Override public
focal_class.parameters: (ModuleId moduleId)
focal_class.return: void
focal_class.signature: void deleteArchive(ModuleId moduleId)
focal_class.class_method_signature: CassandraArchiveRepository.getRows(EnumSet<?> columns)
focal_class.full_signature: protected Iterable<Row<String, String>> getRows(EnumSet<?> columns)
focal_class.identifier: getRows
focal_class.modifiers: protected
focal_class.parameters: (EnumSet<?> columns)
focal_class.return: Iterable<Row<String, String>>
focal_class.signature: Iterable<Row<String, String>> getRows(EnumSet<?> columns)
focal_class.class_method_signature: CassandraArchiveRepository.generateSelectByShardCql(EnumSet<?> columns, Integer shardNum)
focal_class.full_signature: protected String generateSelectByShardCql(EnumSet<?> columns, Integer shardNum)
focal_class.identifier: generateSelectByShardCql
focal_class.modifiers: protected
focal_class.parameters: (EnumSet<?> columns, Integer shardNum)
focal_class.return: String
focal_class.signature: String generateSelectByShardCql(EnumSet<?> columns, Integer shardNum)
focal_class.class_method_signature: CassandraArchiveRepository.verifyHash(byte[] expectedHashCode, byte[] content)
focal_class.full_signature: protected boolean verifyHash(byte[] expectedHashCode, byte[] content)
focal_class.identifier: verifyHash
focal_class.modifiers: protected
focal_class.parameters: (byte[] expectedHashCode, byte[] content)
focal_class.return: boolean
focal_class.signature: boolean verifyHash(byte[] expectedHashCode, byte[] content)
focal_class.class_method_signature: CassandraArchiveRepository.calculateHash(byte[] content)
focal_class.full_signature: protected byte[] calculateHash(byte[] content)
focal_class.identifier: calculateHash
focal_class.modifiers: protected
focal_class.parameters: (byte[] content)
focal_class.return: byte[]
focal_class.signature: byte[] calculateHash(byte[] content)
focal_class.class_method_signature: CassandraArchiveRepository.calculateShardNum(ModuleId moduleId)
focal_class.full_signature: protected int calculateShardNum(ModuleId moduleId)
focal_class.identifier: calculateShardNum
focal_class.modifiers: protected
focal_class.parameters: (ModuleId moduleId)
focal_class.return: int
focal_class.signature: int calculateShardNum(ModuleId moduleId)
focal_class.class_method_signature: CassandraArchiveRepository.getModuleSpec(ColumnList<String> columns)
focal_class.full_signature: private ScriptModuleSpec getModuleSpec(ColumnList<String> columns)
focal_class.identifier: getModuleSpec
focal_class.modifiers: private
focal_class.parameters: (ColumnList<String> columns)
focal_class.return: ScriptModuleSpec
focal_class.signature: ScriptModuleSpec getModuleSpec(ColumnList<String> columns)
focal_class.class_method_signature: CassandraArchiveRepository.getConfig()
focal_class.full_signature: public CassandraArchiveRepositoryConfig getConfig()
focal_class.identifier: getConfig
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: CassandraArchiveRepositoryConfig
focal_class.signature: CassandraArchiveRepositoryConfig getConfig()
focal_method.body: @Override
      public Set<ScriptArchive> getScriptArchives(Set<ModuleId> moduleIds) throws IOException {
          Set<ScriptArchive> archives = new LinkedHashSet<ScriptArchive>(moduleIds.size()*2);
          Path archiveOuputDir = getConfig().getArchiveOutputDirectory();
          List<ModuleId> moduleIdList = new LinkedList<ModuleId>(moduleIds);
          int batchSize = getConfig().getArchiveFetchBatchSize();
          int start = 0;
          try {
              while (start < moduleIdList.size()) {
                  int end = Math.min(moduleIdList.size(), start + batchSize);
                  List<ModuleId> batchModuleIds = moduleIdList.subList(start, end);
                  List<String> rowKeys = new ArrayList<String>(batchModuleIds.size());
                  for (ModuleId batchModuleId:batchModuleIds) {
                      rowKeys.add(batchModuleId.toString());
                  }
  
                  Rows<String, String> rows = cassandra.getRows(rowKeys.toArray(new String[0]));
                  for (Row<String, String> row : rows) {
                      String moduleId = row.getKey();
                      ColumnList<String> columns = row.getColumns();
                      Column<String> lastUpdateColumn = columns.getColumnByName(Columns.last_update.name());
                      Column<String> hashColumn = columns.getColumnByName(Columns.archive_content_hash.name());
                      Column<String> contentColumn = columns.getColumnByName(Columns.archive_content.name());
                      if (lastUpdateColumn == null || hashColumn == null || contentColumn == null) {
                          continue;
                      }
                      ScriptModuleSpec moduleSpec = getModuleSpec(columns);
                      long lastUpdateTime = lastUpdateColumn.getLongValue();
                      byte[] hash = hashColumn.getByteArrayValue();
                      byte[] content = contentColumn.getByteArrayValue();
  
                      // verify the hash
                      if (hash != null && hash.length > 0 && !verifyHash(hash, content)) {
                          logger.warn("Content hash validation failed for moduleId {}. size: {}", moduleId, content.length);
                          continue;
                      }
                      String fileName = new StringBuilder().append(moduleId).append("-").append(lastUpdateTime).append(".jar").toString();
                      Path jarFile = archiveOuputDir.resolve(fileName);
                      Files.write(jarFile, content);
                      JarScriptArchive scriptArchive = new JarScriptArchive.Builder(jarFile)
                          .setModuleSpec(moduleSpec)
                          .setCreateTime(lastUpdateTime)
                          .build();
                      archives.add(scriptArchive);
                  }
                  start = end;
              }
          } catch (Exception e) {
              throw new IOException(e);
          }
          return archives;
      }
focal_method.class_method_signature: CassandraArchiveRepository.getScriptArchives(Set<ModuleId> moduleIds)
focal_method.full_signature: @Override public Set<ScriptArchive> getScriptArchives(Set<ModuleId> moduleIds)
focal_method.identifier: getScriptArchives
focal_method.invocations: size getArchiveOutputDirectory getConfig getArchiveFetchBatchSize getConfig size min size subList size add toString getRows toArray getKey getColumns getColumnByName name getColumnByName name getColumnByName name getModuleSpec getLongValue getByteArrayValue getByteArrayValue verifyHash warn toString append append append append resolve write build setCreateTime setModuleSpec add
focal_method.modifiers: @Override public
focal_method.parameters: (Set<ModuleId> moduleIds)
focal_method.return: Set<ScriptArchive>
focal_method.signature: Set<ScriptArchive> getScriptArchives(Set<ModuleId> moduleIds)