List of usage examples for org.eclipse.jgit.lib RepositoryCache.FileKey open
public static Repository open(Key location) throws IOException, RepositoryNotFoundException
From source file:org.apache.gobblin.service.modules.core.GitConfigMonitorTest.java
License:Apache License
@BeforeClass public void setup() throws Exception { cleanUpDir(TEST_DIR);//from w w w . j av a 2 s . c o m // Create a bare repository RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED); this.remoteRepo = fileKey.open(false); this.remoteRepo.create(true); this.gitForPush = Git.cloneRepository().setURI(this.remoteRepo.getDirectory().getAbsolutePath()) .setDirectory(cloneDir).call(); // push an empty commit as a base for detecting changes this.gitForPush.commit().setMessage("First commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); this.config = ConfigBuilder.create() .addPrimitive( GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_URI, this.remoteRepo.getDirectory().getAbsolutePath()) .addPrimitive( GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TEST_DIR + "/jobConfig") .addPrimitive(FlowCatalog.FLOWSPEC_STORE_DIR_KEY, TEST_DIR + "flowCatalog") .addPrimitive(ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5).build(); this.flowCatalog = new FlowCatalog(config); this.flowCatalog.startAsync().awaitRunning(); this.gitConfigMonitor = new GitConfigMonitor(this.config, this.flowCatalog); this.gitConfigMonitor.setActive(true); }
From source file:org.apache.gobblin.service.modules.core.GitFlowGraphMonitorTest.java
License:Apache License
@BeforeClass public void setUp() throws Exception { cleanUpDir(TEST_DIR);// w ww .j a v a 2s . com // Create a bare repository RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED); this.remoteRepo = fileKey.open(false); this.remoteRepo.create(true); this.gitForPush = Git.cloneRepository().setURI(this.remoteRepo.getDirectory().getAbsolutePath()) .setDirectory(cloneDir).call(); // push an empty commit as a base for detecting changes this.gitForPush.commit().setMessage("First commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); URI topologyCatalogUri = this.getClass().getClassLoader().getResource("topologyspec_catalog").toURI(); Map<URI, TopologySpec> topologySpecMap = MultiHopFlowCompilerTest.buildTopologySpecMap(topologyCatalogUri); this.config = ConfigBuilder.create() .addPrimitive( GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_URI, this.remoteRepo.getDirectory().getAbsolutePath()) .addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TEST_DIR + "/git-flowgraph") .addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5) .build(); // Create a FSFlowTemplateCatalog instance URI flowTemplateCatalogUri = this.getClass().getClassLoader().getResource("template_catalog").toURI(); Properties properties = new Properties(); properties.put(ServiceConfigKeys.TEMPLATE_CATALOGS_FULLY_QUALIFIED_PATH_KEY, flowTemplateCatalogUri.toString()); Config config = ConfigFactory.parseProperties(properties); Config templateCatalogCfg = config.withValue(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY, config.getValue(ServiceConfigKeys.TEMPLATE_CATALOGS_FULLY_QUALIFIED_PATH_KEY)); this.flowCatalog = Optional.of(new FSFlowTemplateCatalog(templateCatalogCfg)); //Create a FlowGraph instance with defaults this.flowGraph = new BaseFlowGraph(); this.gitFlowGraphMonitor = new GitFlowGraphMonitor(this.config, this.flowCatalog, this.flowGraph, topologySpecMap, new CountDownLatch(1)); this.gitFlowGraphMonitor.setActive(true); }
From source file:org.apache.gobblin.service.modules.core.GobblinServiceManagerTest.java
License:Apache License
@BeforeClass public void setup() throws Exception { cleanUpDir(SERVICE_WORK_DIR);//from w ww . j a v a2 s . c o m cleanUpDir(SPEC_STORE_PARENT_DIR); ITestMetastoreDatabase testMetastoreDatabase = TestMetastoreDatabaseFactory.get(); KafkaTestBase kafkaTestHelper = new KafkaTestBase(); kafkaTestHelper.startServers(); Properties serviceCoreProperties = new Properties(); serviceCoreProperties.put(ConfigurationKeys.STATE_STORE_DB_USER_KEY, "testUser"); serviceCoreProperties.put(ConfigurationKeys.STATE_STORE_DB_PASSWORD_KEY, "testPassword"); serviceCoreProperties.put(ConfigurationKeys.STATE_STORE_DB_URL_KEY, testMetastoreDatabase.getJdbcUrl()); serviceCoreProperties.put("zookeeper.connect", kafkaTestHelper.getZkConnectString()); serviceCoreProperties.put(ConfigurationKeys.STATE_STORE_FACTORY_CLASS_KEY, MysqlJobStatusStateStoreFactory.class.getName()); serviceCoreProperties.put(ConfigurationKeys.TOPOLOGYSPEC_STORE_DIR_KEY, TOPOLOGY_SPEC_STORE_DIR); serviceCoreProperties.put(FlowCatalog.FLOWSPEC_STORE_DIR_KEY, FLOW_SPEC_STORE_DIR); serviceCoreProperties.put(ServiceConfigKeys.TOPOLOGY_FACTORY_TOPOLOGY_NAMES_KEY, TEST_GOBBLIN_EXECUTOR_NAME); serviceCoreProperties.put( ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + TEST_GOBBLIN_EXECUTOR_NAME + ".description", "StandaloneTestExecutor"); serviceCoreProperties.put( ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + TEST_GOBBLIN_EXECUTOR_NAME + ".version", FlowSpec.Builder.DEFAULT_VERSION); serviceCoreProperties.put(ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + TEST_GOBBLIN_EXECUTOR_NAME + ".uri", "gobblinExecutor"); serviceCoreProperties.put( ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + TEST_GOBBLIN_EXECUTOR_NAME + ".specExecutorInstance", "org.apache.gobblin.service.InMemorySpecExecutor"); serviceCoreProperties.put(ServiceConfigKeys.TOPOLOGY_FACTORY_PREFIX + TEST_GOBBLIN_EXECUTOR_NAME + ".specExecInstance.capabilities", TEST_SOURCE_NAME + ":" + TEST_SINK_NAME); serviceCoreProperties.put(ServiceConfigKeys.GOBBLIN_SERVICE_GIT_CONFIG_MONITOR_ENABLED_KEY, true); serviceCoreProperties.put( GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_URI, GIT_REMOTE_REPO_DIR); serviceCoreProperties.put( GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, GIT_LOCAL_REPO_DIR); serviceCoreProperties.put( GitConfigMonitor.GIT_CONFIG_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5); serviceCoreProperties.put( FsJobStatusRetriever.CONF_PREFIX + "." + ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY, JOB_STATUS_STATE_STORE_DIR); serviceCoreProperties.put(ServiceConfigKeys.GOBBLIN_SERVICE_JOB_STATUS_MONITOR_ENABLED_KEY, false); // Create a bare repository RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(new File(GIT_REMOTE_REPO_DIR), FS.DETECTED); fileKey.open(false).create(true); this.gitForPush = Git.cloneRepository().setURI(GIT_REMOTE_REPO_DIR).setDirectory(new File(GIT_CLONE_DIR)) .call(); // push an empty commit as a base for detecting changes this.gitForPush.commit().setMessage("First commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(new RefSpec("master")).call(); this.gobblinServiceManager = new GobblinServiceManager("CoreService", "1", ConfigUtils.propertiesToConfig(serviceCoreProperties), Optional.of(new Path(SERVICE_WORK_DIR))); this.gobblinServiceManager.start(); this.flowConfigClient = new FlowConfigClient( String.format("http://localhost:%s/", this.gobblinServiceManager.restliServer.getPort())); }
From source file:org.apache.gobblin.service.modules.flow.MultiHopFlowCompilerTest.java
License:Apache License
@Test(dependsOnMethods = "testMulticastPath") public void testGitFlowGraphMonitorService() throws IOException, GitAPIException, URISyntaxException, InterruptedException { File remoteDir = new File(TESTDIR + "/remote"); File cloneDir = new File(TESTDIR + "/clone"); File flowGraphDir = new File(cloneDir, "/gobblin-flowgraph"); //Clean up/*from w w w . j av a 2 s . com*/ cleanUpDir(TESTDIR); // Create a bare repository RepositoryCache.FileKey fileKey = RepositoryCache.FileKey.exact(remoteDir, FS.DETECTED); Repository remoteRepo = fileKey.open(false); remoteRepo.create(true); Git gitForPush = Git.cloneRepository().setURI(remoteRepo.getDirectory().getAbsolutePath()) .setDirectory(cloneDir).call(); // push an empty commit as a base for detecting changes gitForPush.commit().setMessage("First commit").call(); RefSpec masterRefSpec = new RefSpec("master"); gitForPush.push().setRemote("origin").setRefSpecs(masterRefSpec).call(); URI flowTemplateCatalogUri = this.getClass().getClassLoader().getResource("template_catalog").toURI(); Config config = ConfigBuilder.create() .addPrimitive( GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_URI, remoteRepo.getDirectory().getAbsolutePath()) .addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_REPO_DIR, TESTDIR + "/git-flowgraph") .addPrimitive(GitFlowGraphMonitor.GIT_FLOWGRAPH_MONITOR_PREFIX + "." + ConfigurationKeys.GIT_MONITOR_POLLING_INTERVAL, 5) .addPrimitive(ServiceConfigKeys.TEMPLATE_CATALOGS_FULLY_QUALIFIED_PATH_KEY, flowTemplateCatalogUri.toString()) .build(); //Create a MultiHopFlowCompiler instance specCompiler = new MultiHopFlowCompiler(config, Optional.absent(), false); specCompiler.setActive(true); //Ensure node1 is not present in the graph Assert.assertNull(specCompiler.getFlowGraph().getNode("node1")); // push a new node file File nodeDir = new File(flowGraphDir, "node1"); File nodeFile = new File(nodeDir, "node1.properties"); nodeDir.mkdirs(); nodeFile.createNewFile(); Files.write(FlowGraphConfigurationKeys.DATA_NODE_IS_ACTIVE_KEY + "=true\nparam1=val1" + "\n", nodeFile, Charsets.UTF_8); // add, commit, push node gitForPush.add().addFilepattern(formNodeFilePath(flowGraphDir, nodeDir.getName(), nodeFile.getName())) .call(); gitForPush.commit().setMessage("Node commit").call(); gitForPush.push().setRemote("origin").setRefSpecs(masterRefSpec).call(); // polling is every 5 seconds, so wait twice as long and check TimeUnit.SECONDS.sleep(10); //Test that a DataNode is added to FlowGraph DataNode dataNode = specCompiler.getFlowGraph().getNode("node1"); Assert.assertEquals(dataNode.getId(), "node1"); Assert.assertEquals(dataNode.getRawConfig().getString("param1"), "val1"); }
From source file:org.apache.sshd.git.pack.GitPackCommand.java
License:Apache License
@Override public void run() { try {/* w w w. j a v a 2 s . com*/ List<String> strs = parseDelimitedString(command, " ", true); String[] args = strs.toArray(new String[strs.size()]); for (int i = 0; i < args.length; i++) { if (args[i].startsWith("'") && args[i].endsWith("'")) { args[i] = args[i].substring(1, args[i].length() - 1); } if (args[i].startsWith("\"") && args[i].endsWith("\"")) { args[i] = args[i].substring(1, args[i].length() - 1); } } if (args.length != 2) { throw new IllegalArgumentException("Invalid git command line: " + command); } File srcGitdir = new File(rootDir, args[1]); RepositoryCache.FileKey key = RepositoryCache.FileKey.lenient(srcGitdir, FS.DETECTED); Repository db = key.open(true /* must exist */); if ("git-upload-pack".equals(args[0])) { new UploadPack(db).upload(in, out, err); } else if ("git-receive-pack".equals(args[0])) { new ReceivePack(db).receive(in, out, err); } else { throw new IllegalArgumentException("Unknown git command: " + command); } } catch (Throwable t) { t.printStackTrace(); } if (callback != null) { callback.onExit(0); } }
From source file:playRepository.BareRepository.java
License:Apache License
public static Repository getRepository(Project project) { Repository repository = null;//from w w w. j a v a2 s . co m try { RepositoryCache.FileKey fileKey = RepositoryCache.FileKey .exact(RepositoryService.getRepository(project).getDirectory(), FS.DETECTED); repository = fileKey.open(false); } catch (ServletException | IOException e) { e.printStackTrace(); play.Logger.error(e.getMessage()); } return repository; }