It's all about the answers!

Ask a question

Cost of temporary repository workspaces


Kirk Vogen (1271418) | asked Jun 08 '15, 9:56 a.m.
 Is it expensive from a server storage perspective to create a temporary repository workspace that will soon be deleted? Or, is it possible to retrieve source code from Jazz SCM without a repository workspace?

We are writing a plugin to Jazz SCM for a continuous delivery server (using the RTC Plain Java API). The server polls the plugin asking for the most recent revision. We will implement the concept of revision using Jazz SCM baselines. Later, the server will instruct a build agent to build and will pass it the revision (i.e. baseline). We are thinking that the build agent will create a repository workspace on the fly, replace it with the baseline, get the source, then delete the repository workspace. The end result is that a lot of repository workspaces would be created and deleted in a given day.

Will this have negative ramifications to the RTC server's storage or other resources? Or, are there means to retrieve source code without needing a repository workspace?

Comments
Kirk Vogen commented Jun 08 '15, 10:33 a.m.

I did a little test and was able to get source code directly from the stream without a repository workspace. Both repository workspaces and streams are considered workspaces in the parlance of the Plain Java API. I retrieved a workspace instance of the stream and used the SourceControlUtility to retrieve the source files.


Now, I'm looking into if I can do the retrieval for a particular baseline.

Accepted answer


permanent link
Geoffrey Clemm (30.0k23035) | answered Jun 08 '15, 8:45 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
A repository workspace is very cheap, so I wouldn't spend much/any effort avoiding creating one.
Ralph Schoon selected this answer as the correct answer

Comments
Kirk Vogen commented Jun 10 '15, 9:48 a.m.

Thanks. Since asking the question, I figured out a way to get the source files from the baseline directly (see this answer). Do you think that is an acceptable way to solve the problem?


Or, would it be better to create the temporary repository workspace, set it to the baseline, get the source files, and then delete it?


Geoffrey Clemm commented Jun 12 '15, 1:12 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If getting the files directly from the baseline is working for you, I don't see any reason to create a temporary workspace ... doing so is cheap, but not free.

One other answer



permanent link
Kirk Vogen (1271418) | answered Jun 08 '15, 1:04 p.m.
It looks like it is possible to load the source files for a baseline. You do have to cast a public API interface to its internal implementation. I suppose that means that this technique might not work in the future if the underlying internal implementation changes. Perhaps there is another way to retrieve source files for a baseline that doesn't require using the internal classes.

Here is some code that retrieves the source files for a baseline. The code requires some clean-up to be used "for real", but should at least illustrate how to do it.
        ITeamRepository repo = ... // Get instance of ITeamRepository
        
        IWorkspaceManager workspaceManager = (IWorkspaceManager) repo.getClientLibrary(IWorkspaceManager.class);
        
        IComponentSearchCriteria componentSearchCriteria = IComponentSearchCriteria.FACTORY.newInstance();
        componentSearchCriteria.setExactName("YourComponent");
        List<IComponentHandle> componentList = workspaceManager.findComponents(
                componentSearchCriteria, 10, new NullProgressMonitor());
        assertEquals(1, componentList.size());
        
        String baselineName = "YourBaselineName";
        
        IBaselineSearchCriteria searchCriteria = IBaselineSearchCriteria.FACTORY.newInstance();
        searchCriteria.setExactName(baselineName);
        searchCriteria.setComponentRequired(componentList.get(0));
        
        List<IBaselineHandle> baselines = workspaceManager.findBaselines(searchCriteria, 2,
                new NullProgressMonitor());
        
        if (baselines.size() == 0) 
        {
            fail("Expected one baseline with the name: " + baselineName);
        }
        else if (baselines.size() > 1)
        {
            fail("Expected only one baseline with the name: " + baselineName);
        }
        
        IBaseline baseline = (IBaseline) repo.itemManager().fetchCompleteItem(baselines.get(0),
                IItemManager.DEFAULT, new NullProgressMonitor());
        assertThat(baseline, not(nullValue()));
        IBaselineConnection baselineConnection = workspaceManager.getBaselineConnection(
                baselines.get(0), new NullProgressMonitor());
        assertThat(baselineConnection, not(nullValue()));
        
        File temp = File.createTempFile("src", "");
        temp.delete();
        temp.mkdir();
        String sourcePath = temp.getAbsolutePath();
        temp.deleteOnExit();
        System.out.println(sourcePath);
        
        ISandbox sandbox = FileSystemCore.getSharingManager().getSandbox(new PathLocation(sourcePath), false);
        
        ILoadOperation loadOp = IOperationFactory.instance.getLoadOperation(new LoadDilemmaHandler() {});

        assertThat(loadOp, instanceOf(LoadOperation.class));
        
        LoadOperation loadOpCasted = (LoadOperation) loadOp;

        loadOpCasted.requestLoad(sandbox, null, baselineConnection,
                baselineConnection.configuration().childEntriesForRoot(null).values());
        loadOp.run(new NullProgressMonitor());

Your answer


Register or to post your answer.