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: @SuppressWarnings({ "rawtypes", "unchecked" })
      @Test
      public void testInsertArchive() throws IOException {
          JarScriptArchive jarArchive = new JarScriptArchive.Builder(testArchiveJarFile).build();
          repository.insertArchive(jarArchive);
  
          Map<String, Object> columns = new HashMap<String, Object>();
          Path jarFilePath;
          try {
              jarFilePath = Paths.get(jarArchive.getRootUrl().toURI());
          } catch (URISyntaxException e) {
              throw new IOException(e);
          }
          ScriptModuleSpec moduleSpec = jarArchive.getModuleSpec();
          String serialized = config.getModuleSpecSerializer().serialize(moduleSpec);
          byte[] jarBytes = Files.readAllBytes(jarFilePath);
          columns.put(Columns.shard_num.name(), repository.calculateShardNum(moduleSpec.getModuleId()));
          columns.put(Columns.last_update.name(), jarArchive.getCreateTime());
          columns.put(Columns.archive_content.name(), jarBytes);
          columns.put(Columns.archive_content_hash.name(), repository.calculateHash(jarBytes));
          columns.put(Columns.module_spec.name(), serialized);
  
          ArgumentCaptor<String> argument1 = ArgumentCaptor.forClass(String.class);
          ArgumentCaptor<Map> argument2 = ArgumentCaptor.forClass(Map.class);
          verify(gateway).upsert(argument1.capture(),
                  argument2.capture());
  
          assertEquals(moduleSpec.getModuleId().toString(), argument1.getValue());
          Map columnMap = argument2.getValue();
          assertEquals(repository.calculateShardNum(moduleSpec.getModuleId()), columnMap.get(Columns.shard_num.name()));
          assertTrue(Arrays.equals(jarBytes, (byte[])columnMap.get(Columns.archive_content.name())));
          assertTrue(Arrays.equals(repository.calculateHash(jarBytes), (byte[])columnMap.get(Columns.archive_content_hash.name())));
          assertEquals(serialized, (String)columnMap.get(Columns.module_spec.name()));
          assertEquals(jarArchive.getCreateTime(), (long)columnMap.get(Columns.last_update.name()));
      }
test_case.class_method_signature: CassandraArchiveRepositoryTest.testInsertArchive()
test_case.full_signature: @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testInsertArchive()
test_case.identifier: testInsertArchive
test_case.invocations: build insertArchive get toURI getRootUrl getModuleSpec serialize getModuleSpecSerializer readAllBytes put name calculateShardNum getModuleId put name getCreateTime put name put name calculateHash put name forClass forClass upsert verify capture capture assertEquals toString getModuleId getValue getValue assertEquals calculateShardNum getModuleId get name assertTrue equals get name assertTrue equals calculateHash get name assertEquals get name assertEquals getCreateTime get name
test_case.modifiers: @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInsertArchive()
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 void insertArchive(JarScriptArchive jarScriptArchive) throws IOException {
          Objects.requireNonNull(jarScriptArchive, "jarScriptArchive");
          ScriptModuleSpec moduleSpec = jarScriptArchive.getModuleSpec();
          ModuleId moduleId = moduleSpec.getModuleId();
          Path jarFilePath;
          try {
              jarFilePath = Paths.get(jarScriptArchive.getRootUrl().toURI());
          } catch (URISyntaxException e) {
              throw new IOException(e);
          }
          int shardNum = calculateShardNum(moduleId);
          byte[] jarBytes = Files.readAllBytes(jarFilePath);
          byte[] hash = calculateHash(jarBytes);
          Map<String, Object> columns = new HashMap<String, Object>();
          columns.put(Columns.module_id.name(), moduleId.toString());
          columns.put(Columns.module_name.name(), moduleId.getName());
          columns.put(Columns.module_version.name(), moduleId.getVersion());
          columns.put(Columns.shard_num.name(), shardNum);
          columns.put(Columns.last_update.name(), jarScriptArchive.getCreateTime());
          columns.put(Columns.archive_content_hash.name(), hash);
          columns.put(Columns.archive_content.name(), jarBytes);
  
          String serialized = getConfig().getModuleSpecSerializer().serialize(moduleSpec);
          columns.put(Columns.module_spec.name(), serialized);
          try {
              cassandra.upsert(moduleId.toString(), columns);
          } catch (Exception e) {
              throw new IOException(e);
          }
      }
focal_method.class_method_signature: CassandraArchiveRepository.insertArchive(JarScriptArchive jarScriptArchive)
focal_method.full_signature: @Override public void insertArchive(JarScriptArchive jarScriptArchive)
focal_method.identifier: insertArchive
focal_method.invocations: requireNonNull getModuleSpec getModuleId get toURI getRootUrl calculateShardNum readAllBytes calculateHash put name toString put name getName put name getVersion put name put name getCreateTime put name put name serialize getModuleSpecSerializer getConfig put name upsert toString
focal_method.modifiers: @Override public
focal_method.parameters: (JarScriptArchive jarScriptArchive)
focal_method.return: void
focal_method.signature: void insertArchive(JarScriptArchive jarScriptArchive)