public CDONet4jSession createSession() { IManagedContainer container = IPluginContainer.INSTANCE; IJVMConnector connector = JVMUtil.getConnector(container, "default"); CDONet4jSessionConfiguration config = CDONet4jUtil.createNet4jSessionConfiguration(); config.setConnector(connector); config.setRepositoryName(ServerConstants.REPOSITORY_NAME); CDONet4jSession session = config.openNet4jSession(); // see https://github.com/jutzig/jabylon/issues/148 // disableing the chunking for now in case this is the root cause session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(-1, -1)); session.getPackageRegistry().putEPackage(PropertiesPackage.eINSTANCE); session.getPackageRegistry().putEPackage(UsersPackage.eINSTANCE); return session; }
protected void initialize() throws CommitException { startRepository(); CDONet4jSession session = createSession(); CDOTransaction transaction = session.openTransaction(); try { initializeWorkspace(transaction); initializeUserManagement(transaction); FrameworkUtil.getBundle(getClass()).getBundleContext().registerService(IAcceptor.class, acceptor, null); } catch (CommitException e) { logger.error("Failed to initialize repository", e); } finally { transaction.close(); session.close(); } }
public CDOView openView(CDONet4jSession session) { return configureView(session.openView()); }
private List<CDOCommitInfo> getAllCDOCommitInfos() { final CDONet4jSession session = getConnection().getSession(); Map<Integer, CDOBranch> existingCDOBranches = newHashMap(); CDOBranch mainBranch = session.getBranchManager().getMainBranch(); existingCDOBranches.put(mainBranch.getID(), mainBranch); ConsumeAllCDOBranchesHandler branchHandler = new ConsumeAllCDOBranchesHandler(); session.getBranchManager().getBranches(0, Integer.MAX_VALUE, branchHandler); branchHandler.getBranches().forEach( b -> existingCDOBranches.put(b.getID(), b)); final CDOCommitInfoManager commitInfoManager = session.getCommitInfoManager(); final ConsumeAllCommitInfoHandler handler = new ConsumeAllCommitInfoHandler(); commitInfoManager.getCommitInfos(null, CDOCommitInfo.UNSPECIFIED_DATE, CDOCommitInfo.UNSPECIFIED_DATE, handler); return handler.getInfos().stream() .filter(commitInfo -> !CDOCommitInfoUtils.CDOCommitInfoQuery.EXCLUDED_USERS.contains(commitInfo.getUserID()) && existingCDOBranches.containsKey(commitInfo.getBranch().getID())) .collect(Collectors.toList()); }
public CDOView getView(URI uri, ResourceSet resourceSet) { CDOURIData data = new CDOURIData(uri); IConnector connector = getConnector(data.getAuthority()); CDONet4jSession session = getNet4jSession(connector, data.getUserName(), data.getPassWord(), data.getRepositoryName()); String viewID = data.getViewID(); if (viewID != null) { if (data.isTransactional()) { return session.openTransaction(viewID, resourceSet); } return session.openView(viewID, resourceSet); } String branchPath = data.getBranchPath().toPortableString(); CDOBranch branch = session.getBranchManager().getBranch(branchPath); long timeStamp = data.getTimeStamp(); if (data.isTransactional()) { return session.openTransaction(branch, resourceSet); } return session.openView(branch, timeStamp, resourceSet); }
@Override protected int getMonitorProgressSeconds() { org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)getSession(); return session.options().getProgressInterval(); }
IConnector connector = (IConnector)session.options().getNet4jProtocol().getChannel().getMultiplexer(); String repositoryName = session.getRepositoryInfo().getName(); append(builder, connector, repositoryName);
/** * Getter for transaction including lazy initialization * * @return the transaction */ public CDOTransaction openTransaction() { return configureView(getSession().openTransaction()); }
if(session!=null) session.close();
private static CDOCommitInfo createCommitInfo(final CDOBranch branch, final long timeStamp, final long previousTimeStamp, final CDOChangeSetData changeSetData) { final ICDOConnection connection = getConnectionManager().get(branch); final CDONet4jSession session = connection.getSession(); final InternalCDOCommitInfoManager commitInfoManager = (InternalCDOCommitInfoManager) session.getCommitInfoManager(); return commitInfoManager.createCommitInfo( branch, timeStamp, previousTimeStamp, null, //user ID (intentionally ignored ) null, //commit comment (intentionally ignored) createCommitData(changeSetData)); }
@Override protected int getMonitorTimeoutSeconds() { org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)getSession(); return session.options().getCommitTimeout(); }
final CDOCommitInfoManager commitInfoManager = connection.getSession().getCommitInfoManager();
@Override public CDONet4jSession createSession() { IManagedContainer container = IPluginContainer.INSTANCE; if (connector == null) connector = JVMUtil.getConnector(container, "default"); CDONet4jSessionConfiguration config = CDONet4jUtil.createNet4jSessionConfiguration(); config.setConnector(connector); config.setRepositoryName(REPOSITORY_NAME); CDONet4jSession theSession = config.openNet4jSession(); theSession.options().setCollectionLoadingPolicy (CDOUtil.createCollectionLoadingPolicy(CDORevision.UNCHUNKED, CDORevision.UNCHUNKED)); theSession.getPackageRegistry().putEPackage(PropertiesPackage.eINSTANCE); theSession.getPackageRegistry().putEPackage(UsersPackage.eINSTANCE); return theSession; }
private void hookListener(final RepositoryConnector repositoryConnector) { CDONet4jSession session = repositoryConnector.createSession(); session.options().setPassiveUpdateMode(PassiveUpdateMode.ADDITIONS); CDOView view = repositoryConnector.openView(session); view.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL); CDOResource resource = view.getResource(ServerConstants.WORKSPACE_RESOURCE); workspace = (Workspace) resource.getContents().get(0); cache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).concurrencyLevel(5).maximumWeight(50000).weigher(new PropertySizeWeigher()).build(new PropertyFileCacheLoader(repositoryConnector.openView(session))); //this is very expensive, so don't do it during the bind phase new Thread(new Runnable() { @Override public void run() { long time = System.currentTimeMillis(); workspace.eAdapters().add(new ListeningAdapter()); LOGGER.info("Installed EContentAdapter in {} seconds",(System.currentTimeMillis()-time)/1000); } },"Install Persistence Listener").start(); }
@Override public CDOView openView() { return configureView(getSession().openView()); }
protected Collection<? extends IHistoryInfoDetails> processNewObjects(final List<CDOIDAndVersion> newObjects, final CDOView beforeView, final CDOView currentView, final boolean shouldInvalidate) { final List<IHistoryInfoDetails> infoDetails = new ArrayList<IHistoryInfoDetails>(); for (final CDOIDAndVersion idAndVersion : newObjects) { final CDOID cdoid = ((CDORevision) idAndVersion).getID(); final CDOObject object = CDOUtils.getObjectIfExists(currentView, cdoid); if (null == object) { //object was created on the main branch we have to open a view on the main branch final ICDOConnectionManager connectionManager = ApplicationContext.getInstance().getService(ICDOConnectionManager.class); final ICDOConnection connection = connectionManager.get(currentView); final CDOBranch mainBranch = connection.getMainBranch(); final CDOView cdoMainView = connection.getSession().openView(mainBranch, currentView.getTimeStamp(), shouldInvalidate); try { IHistoryInfoDetails details = generateInfoForNewObject(cdoMainView.getObject(cdoid), beforeView, cdoMainView); if (IHistoryInfoDetails.IGNORED_DETAILS != details) { infoDetails.add(details); } } finally { cdoMainView.close(); } } else { final IHistoryInfoDetails details = generateInfoForNewObject(object, beforeView, currentView); if (IHistoryInfoDetails.IGNORED_DETAILS != details) { infoDetails.add(details); } } } return infoDetails; }
final ICDOConnectionManager connectionManager = ApplicationContext.getInstance().getService(ICDOConnectionManager.class); final ICDOConnection connection = connectionManager.get(idAndVersion.getID()); final CDOView beforeCdoView = connection.getSession().openView(beforeView.getBranch(), beforeView.getTimeStamp(), false); try { final CDOID cdoid = idAndVersion.getID(); if (null == object) { //object has been deleted on main we should open a view on the main branch final CDOBranch mainBranch = connection.getMainBranch(); final CDOView beforeMainCdoView = connection.getSession().openView(mainBranch, beforeView.getTimeStamp() - 1, false); try { final IHistoryInfoDetails details = generateInfoForDetachedObject(beforeMainCdoView.getObject(cdoid), beforeMainCdoView, currentView);