Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "PTP/designs/remote/sync final"

< PTP‎ | designs‎ | remote
(Multiple Hosts)
(Support for Non-CDT Projects)
 
(44 intermediate revisions by the same user not shown)
Line 21: Line 21:
 
* '''Synchronized projects should be independent of Team support.''' Although there is a temptation to use synchronization for sharing project code, synchronized support is really orthogonal to Team support since it does not provide the same richness of features of revision control systems. Synchronization is primarily for keeping two copies of code in sync. In the current implementation, synchronized projects can also be shared with any of the Team providers that are available in Eclipse.
 
* '''Synchronized projects should be independent of Team support.''' Although there is a temptation to use synchronization for sharing project code, synchronized support is really orthogonal to Team support since it does not provide the same richness of features of revision control systems. Synchronization is primarily for keeping two copies of code in sync. In the current implementation, synchronized projects can also be shared with any of the Team providers that are available in Eclipse.
  
The synchronization framework is designed to be extensible, so that different synchronization providers can be provided to suit different environments. This is achieved using the [[PTP/designs/services | services framework]] provided by PTP. To add a new synchronization provider, a plugin must supply a class that implements the <code>ISyncServiceProvider</code> interface, then register this class using the <code>org.eclipse.ptp.services.core.providers</code> extension point. The services framework will then manage loading the class at the correct time, persisting data, etc.
+
== Synchronization Service ==
 +
 
 +
The synchronization framework is designed to be extensible, so that different synchronization providers can be provided to suit different environments. This is achieved by adding a new service called <code>org.eclipse.ptp.rdt.sync.core.SyncService</code> to the [[PTP/designs/services | services framework]] provided by PTP. To add a new synchronization provider, a plugin must supply a class that implements the <code>ISyncServiceProvider</code> interface, then registers this class using the <code>org.eclipse.ptp.services.core.providers</code> extension point. The services framework will then manage loading the class at the correct time, persisting data, etc.
 +
 
 +
=== APIs ===
 +
 
 +
The <code>ISyncServiceProvider</code> provides the following methods:
 +
 
 +
; <code>public String getLocation()</code> : Get the build location specified by this sync service provider.
 +
; <code>public IRemoteConnection getRemoteConnection()</code> : Get the remote connection used by this sync service provider.
 +
; <code>public void synchronize(IProject, BuildScenario, IResourceDelta, SyncFileFilter, IProgressMonitor, EnumSet<SyncFlag>)</code> : Synchronize a project (represented by the <code>IProject</code> object) using the <code>BuildScenario</code> and filters specified by <code>SyncFileFilter</code>. If an <code>IResourceDelta</code> is supplied, then only resources in the delta will be synchronized. The <code>SyncFlag</code>s control the behavior of the synchronization.
 +
; <code>public Set<IPath> getMergeConflictFiles(IProject project, BuildScenario buildScenario)</code> : Get the current list of merge-conflicted files for the project and build scenario
 +
; <code>public String[] getMergeConflictParts(IProject project, BuildScenario buildScenario, IFile file)</code> : Get the three parts of the merge-conflicted file (left, right, and ancestor, respectively)
 +
; <code>public void setMergeAsResolved(IProject project, BuildScenario buildScenario, IPath[] paths)</code> :  Set the given file paths as resolved (merge conflict does not exist)
 +
; <code>public void checkout(IProject project, BuildScenario buildScenario, IPath[] paths)</code> : Replace the current contents of the given paths with the previous versions in the repository
 +
; <code>public void checkoutRemoteCopy(IProject project, BuildScenario buildScenario, IPath[] paths)</code> : Replace the current contents of the given paths with the current local copies of the remote (not necessarily the same as what is on the remote site). This is useful in merge-conflict resolution.
 +
; <code>public void close(IProject project)</code> :  Close any resources that were open by the sync provider for the given project. Resources not open by the provider should not be touched. This is called, for example, when a project is about to be deleted.
 +
 
 +
=== User Interface ===
 +
 
 +
The synchronization user interface is provided using the context menu on a project, as shown below.
 +
 
 +
[[image:context_menu.png]]
 +
 
 +
The "Synchronization" menu provides the following options and commands:
 +
 
 +
; '''Auto-Sync''' : Enable/disable automatic synchronization for all projects (global option). If enabled, synchronization will take place when a resource is modified, prior to a build, and immediately after a build. If disabled, synchronization will only happen if the user selects one of the synchronization actions.
 +
; '''Project Auto-Sync Settings''' : Sets the auto synchronization settings for the current project. If set to '''Sync-Active''' only the active configuration will be synchronized. If set to '''Sync-All''', all configurations will be synchronized in sequence. If set to '''Sync-None''' the no configurations will be synchronized. This is the same as disabling '''Auto-Sync''', but for a single project only.
 +
; '''Sync Active Now''' : This command will immediately synchronize using the active configuration of the current project.
 +
; '''Sync All Now''' : This command will immediately synchronize all configurations of the current project.
 +
; '''Filter...''' : Open the synchronization filter dialog to configure filters for this project. Filtering is described in more detail in [[#Filtering|Filtering]].
  
 
== Project Nature ==
 
== Project Nature ==
Line 37: Line 67:
 
Synchronization to multiple hosts is supported using the <code>BuildScenario</code> class. An object of this class is passed to the <code>ISyncServiceProvider#synchronize()</code> method along with the project reference. A <code>BuildScenario</code> encapsulates the connection and location information for the project on the remote target system. By maintaining multiple <code>BuildScenario</code>s, it is possible to perform synchronization to multiple systems.
 
Synchronization to multiple hosts is supported using the <code>BuildScenario</code> class. An object of this class is passed to the <code>ISyncServiceProvider#synchronize()</code> method along with the project reference. A <code>BuildScenario</code> encapsulates the connection and location information for the project on the remote target system. By maintaining multiple <code>BuildScenario</code>s, it is possible to perform synchronization to multiple systems.
  
For CDT projects, the <code>BuildScenario</code> information is stored in the project build configuration (<code>IConfiguration</code> interface). The framework provides the <code>BuildConfigurationManager</code> class for managing the interface between the synchronization framework and CDT's build configurations.
+
For CDT projects, the <code>BuildScenario</code> information is stored in the project build configuration (<code>IConfiguration</code> interface). The framework provides the <code>BuildConfigurationManager</code> class for managing the interface between the synchronization framework and CDT's build configurations.  
  
# Where will synchronization information be stored?
+
CDT provides the notion of an "active" build configuration, so the synchronization framework uses this as the default configuration when synchronizing the project. The user interface also provides a means of synchronizing all build configurations, which will cause the project to be synchronized with each target system that has been configured.
#* Service configurations will be used to store connection information
+
#* Remote system information will be saved in the user's workspace using the service configuration mechanism (so that it ties into the other parts of PTP)
+
#* Service configurations will also specify the different sync methods (and sync method-specific information)
+
# How will synchronization be controlled?
+
#* The current plan is to use build configurations to control synchronization
+
#* Each build configuration will include the target system name (e.g. target1_release, target1_debug, target2_debug, etc.)
+
#* The "active" configuration will specify the synchronization point (target system + project location) for synchronization
+
#* Building a non-active configuration will automatically switch the "active" configuration
+
#* If the user has selected Indexer->"Use active build configuration", changing the "active" configuration will result in a re-synchronization and index rebuild
+
#* If the user has selected Indexer->"Use fixed build configuration", this "fixed" configuration and its associated target machine is used for the index. With this option selected, the index is not rebuild when switching the active build configuration, but only when changing the "fixed" build configuration.
+
# How will off-line development be supported?
+
#* TBD
+
  
= Possible Back-ends =
+
[[image:multi_sync.png]]
Rsync and GIT both have advantages and disadvantages. Thus it sounds reasonable to support at least those two and make it easy to add others later on.
+
== Advantages of Rsync ==
+
* widely available. And thus easy to set-up without installing software on the remote machine
+
* others:TBD
+
== Disadvantages of Rsync ==
+
Status of Java implementation is uncertain
+
* http://sourceforge.net/projects/jarsync
+
Alternatives
+
* Using the command line tool instead has several disadvantages:
+
** Support for Windows
+
** Passing Password/Not possible to share same connection
+
** Reliance on external tool
+
* C Library is available (librsync) but would require e.g. JNI, NestedVM
+
* Java libraries that support file synchronization without being compatible with Rsync (e.g. JFileSync). OK because we could upload Server automatically. But protocol should be fast and reliable.
+
+
* The synchronization is only one-way
+
* Problems if clocks are not synchronized between systems
+
The two-way is important if, either automatically or by the user, remote files get changed. The one-way
+
synchronization of rsync would usually not synchronize changes to the client
+
and would not detect conflicts caused by changes on both sides very well.
+
  
== Advantages of GIT ==
+
In the above diagram, a project is being synchronized to three remote hosts, A, B, and C. The "active" configuration is currently set to host A, so when a build or synchronize is performed, it will automatically use that host.The user can override this by use the "Build All" or "Synchronize All Now" menus.
* It has a java implementation (shipping with Helios)
+
* Java can also be used on the server (if native is not available)
+
* is known to be extremely fast (including the java implementation)
+
* supports two way synchronization.  
+
Of course GIT is not meant as a synchronization tool (but a DCVS) but it works as
+
a synchronization tool extremely well. Using git for synchronization would work
+
both for those users using it also for version control and for those users
+
using some other tool for version control.
+
As an example a remote synchronization of a folder containing ~4000files (1
+
changed - which unknown to GIT), ~100MB, where GIT detects file changes on both
+
sides, over a remote connection (cable), takes less than one second. The
+
performance is mainly limited by the file system for the tree traversal.
+
  
== Implementation Issues with GIT ==
+
== Wizards ==
=== To push to a non-bare repository is discouraged ===
+
Their are different options
+
* Fetch (not good option because it requires SSHD on the client)
+
* Push into working branch with [http://utsl.gen.nz/git/post-update post-update hook]. Disadvantages: Requires stat of each file on server (slow over NFS) and doesn't allow merge on client side
+
* Push to separate bare repository. Disadvantage: Requires 2 repositories
+
* [http://thread.gmane.org/gmane.comp.version-control.git/42506/focus=42685 Push to remote branch]. Seems best option
+
  
=Preprocessing & Indexing=
+
Synchronized projects are created using one of two available wizards. A new synchronized project can be created from scratch, or from an existing remote project, using the '''Synchronized Project''' wizard. An existing local project can also be converted to a synchronized project (and hence synchronized to a remote system) using the '''Convert To Synchronized Project''' wizard.
 +
 
 +
=== Synchronized Project Wizard ===
 +
 
 +
This wizard is used to create a new synchronized project from scratch, or to synchronize with an existing remote project. It comes in two flavors, one for creating C/C++ projects, and one for creating Fortran projects. The only difference between these is that the latter wizard adds a Fortran nature to the project, so should be used if the project is likely to contain any Fortran code. The user interface is shown below.
 +
 
 +
[[image:new_wizard.png]]
 +
 
 +
The wizard is similar to the normal '''C Project''' or '''C++ Project''' wizards in that it allows the user to specify a project name, location, select the project type, and choose the toolchain. In addition to these however, the wizard allows the user to select a remote location for the project, which is the location that will be used to synchronize the remote files, and a remote toolchain that specifies the toolchain that will be used on the remote machine. If the remote project location already contains resources, then these will be synchronized with the local project immediately upon completion of the wizard.
 +
 
 +
=== Convert To Synchronized Project Wizard ===
 +
 
 +
As its name implies, this wizard is used to convert an existing C, C++, or Fortran project to be synchronized, which requires adding a remote location and remote toolchain to the project. When the wizard is first invoked, it will scan the workspace for any non-synchronized CDT projects. The user is then able to select the projects for conversion from a list, and once a remote location is chosen, the project will be converted. This process duplicates the selected configurations and adds the remote location to them. If a different toolchain needs to be selected for the remote configurations, the user must manually edit the build configuration for each remote configuration. The user interface for this wizard is shown below.
 +
 
 +
[[image:convert_wizard.png]]
 +
 
 +
== Filtering ==
 +
 
 +
Being able to specify which files are synchronized is essential, especially for projects that contain large numbers of object files or large data files that are not necessary for application development. Filtering is provided on a per-project basis, and can be used to specify exactly which resources are included or excluded from the synchronization. Default filters can also be set in the Eclipse settings, and these are inherited by a synchronized project when it is created. By default, the following resources are excluded: <code>.ptp-sync</code>, <code>.settings</code>, <code>.cproject</code>, and <code>.project</code>.
 +
 
 +
=== APIs ===
 +
 
 +
Resource filtering is provided using the <code>SyncFileFilter</code> class which is passed to the <code>ISyncProvider#synchronize()</code> method, which maintains a list of patterns (which extend the abstract base class <code>ResourcePattern</code>) that are to be included in the the synchronization and list that are to be excluded from the synchronization.
 +
 
 +
In the current implementation, two types of filter patterns are available:
 +
 
 +
; <code>PathResourceMatcher</code> : This filter tests resources against a specific directory path.
 +
; <code>RegexPatternMatcher</code> : This filter tests resources against a regular expression.
 +
 
 +
=== User Interface ===
 +
 
 +
Filtering can be configured when creating a synchronized project or converting a project to use synchronization. Filters can also be configured at any time using the synchronization context menu on the project. The following user interface is used for configuration filtering on a project.
 +
 
 +
[[image:filter_config.png]]
 +
 
 +
The '''File View''' area is used to include or exclude resources directly (using the checkbox next to the resource), and will also show which files are being included or excluded based on the patterns. The '''Pattern View''' shows the currently defined patterns and allows the pattern ordering to be altered. Patterns are applied in order from top to bottom. A new path or regex pattern can be added by entering the information in the appropriate text field and selecting either the '''Exclude''' or '''Include''' buttons as required.
 +
 
 +
== Off-line Operation ==
 +
 
 +
One of the advantages of synchronized projects over remote projects is the ability to operate without a network connection. Off-line operation is automatically managed by the use of asynchronous synchronize operations. If a connection to the target system is unavailable, the operation will be queued in order until network connectivity is restored, at which time the operations will be performed. The user does not need to take any action for this automatic behavior to be enabled.
 +
 
 +
A caveat to off-line operation is that building remotely while off-line is not possible. If the user attempts to build while off-line, then the build will fail and any subsequent synchronization operations will be discarded. '''[verify this behavior]'''
 +
 
 +
== Scanner Discovery & Include Files ==
  
 
Many of the advanced features of CDT and Photran require indexing/parsing the source code. When a project is being built remotely, the source code presented to the user should reflect the environment on the remote system rather than the local system. The main mechanisms that distinguish a remote environment from the local environment are the macros that are predefined by the compiler and the system include files that are included in the source code.
 
Many of the advanced features of CDT and Photran require indexing/parsing the source code. When a project is being built remotely, the source code presented to the user should reflect the environment on the remote system rather than the local system. The main mechanisms that distinguish a remote environment from the local environment are the macros that are predefined by the compiler and the system include files that are included in the source code.
  
 
Note that this support is independent of remote synchronization (although may use some remote synchronization functionality to achieve it). A remotely synchronized project can still use a purely local environment without requiring any additional functionality.
 
Note that this support is independent of remote synchronization (although may use some remote synchronization functionality to achieve it). A remotely synchronized project can still use a purely local environment without requiring any additional functionality.
 
== System Include Files ==
 
  
 
To present an accurate reflection of the remote environment, system include files need to be fetched from the remote system for the preprocessor and indexer. This requires changes to the preprocessor and other parts of CDT/Photran in order to obtain the header file from the correct remote system rather than from the local system. To avoid performance issues, header files should also be cached locally where possible, but this must be an option as licensing issues may prevent it on some systems.
 
To present an accurate reflection of the remote environment, system include files need to be fetched from the remote system for the preprocessor and indexer. This requires changes to the preprocessor and other parts of CDT/Photran in order to obtain the header file from the correct remote system rather than from the local system. To avoid performance issues, header files should also be cached locally where possible, but this must be an option as licensing issues may prevent it on some systems.
 
   
 
   
== Scanner Discovery ==
 
 
 
Compiler (and makefile) defined macros play an important part in determining which header files will be included as well as which parts of the code will be enabled or disabled. CDT attempts to determine these macros using a process known as scanner discovery. This involves running commands on the target system to determine the macros that are defined. This process is inherently complex because every system has different compilers with different options for determining this information. RDT has already provided some remote scanner discovery functionality, so we plan to reuse this for synchronized projects.
 
Compiler (and makefile) defined macros play an important part in determining which header files will be included as well as which parts of the code will be enabled or disabled. CDT attempts to determine these macros using a process known as scanner discovery. This involves running commands on the target system to determine the macros that are defined. This process is inherently complex because every system has different compilers with different options for determining this information. RDT has already provided some remote scanner discovery functionality, so we plan to reuse this for synchronized projects.
  
=Support for other Remote Tools besides Build=
+
= Synchronization Provider Implementations =
TBD
+
  
=Milestones=
+
Currently the only mature synchronization provider uses the Git protocol to manage synchronization. Some work has been undertaken to develop a provider based on Rsync, but to date this has not been completed. The Git provider uses the JGit feature to provide a Java implementation of Git for Eclipse. Git also has the advantage of being very fast, even for a large number of small commits.
  
* Check feasibility of remote include path support in CDT (see [[#Preprocessing & Indexing]])
+
It is outside the scope of this document to describe the details of the Git implementation.
* Define a new Synchronization service type (which add synchronization/replication to the running EFS). It would have as public method guranteeSynchronized. The default server (for a purely local project or for remotetools/RSE) would do nothing.
+
* Add to all remote operations (compile, remote index, ..) a call to gureanteeSyncronized
+
* Implement a GIT based synchronization service (doing the GIT push in the gureanteeSyncronized call)
+
* Add the GUI to configure the synronization service (including new project wizard)
+
  
Later an EFS which would do the asynchronous GIT push after a file modifcation(e.g. save) and the gureanteeSyncronized would just wait for the
+
= Support for Non-CDT Projects =
push to finish.
+
  
Timeline: TBD
+
The current implementation of synchronized projects relies on the build configuration properties of CDT projects for a number of reasons. Project building and synchronization are closely related, since the purpose of synchronizing a project is generally to support remote building. CDT's build configurations provide a simple mechanism for supporting synchronization to multiple hosts, since each host can be associated with a build configuration, and the configuration augmented to include the location of the remote project. The "active" synchronization host then automatically corresponds to the "active" build configuration. Another advantage of using CDT's build configurations is that the configuration information is stored with the project, so moving the project to a different workspace automatically preserves the synchronization information.
  
=Additional Features=
+
In order to support the synchronization of other projects, such as Java or Python, the synchronization configuration information needs to be maintained in a different manner. This could be either using a project-specific location (such as CDT's build configurations) or as generic information in the project properties. In addition, building these projects remotely requires a different remote builder implementation, since they are unlikely to use Makefiles as their primary build mechanism.
==Remote file view==
+
To run the binary it is required to select it on the remote machine. For that it would be nice to be able to browse the remote machine using RemoteTools/RSE. Preferable the path shown is the path to the remote copy of the local project. Also it would be nice to have a "Project Explorer" View for the files on the remote machines. This would allow to view binaries, object files and other remote files not part of the synchronization. This view should also use RemoteTools/RSE
+
==Build local and remote from same project==
+
If the remote build is implemented as a builder which can be added to a standard CDT/Photran project, than it is possible to have both a local and remote builder for the same project. CDT already supports several builder configuration. Thus this can be used to switch between local and (potentially several) remote builder. It has to be checked that the indexer (including the remote include files) is updated correctly when the builder configuration switches.
+

Latest revision as of 18:23, 9 October 2012

Introduction

This document describes the design of the Remote Project Synchronization framework. It is based on the original proposal by Roland Schulz and others

Eclipse projects (including C/C++ projects) are traditionally stored on the local filesystem of the machine on which Eclipse is running. This is adequate for Java, since the bytecode is inherently portable, and for embedded development, since a cross-compiler environment is typically employed. However it does not suit the development of HPC applications because it is generally very difficult to replicate the environment of the target system on the local machine. In order to overcome this limitation, the Remote Development Tools (RDT) component of PTP added support for remote projects. However, the approach taken has a number of serious limitations that preclude it being used to develop many applications. Although the functionality of RDT has improved, the main issues that still remains outstanding is that it only supports C/C++ projects and is not a general solution that can be used for other languages and project types.

Remote Project Synchronization is an alternative to RDT that overcomes many of RDT's inherent limitations. Synchronized projects work by maintaining both local and a remote copies of the source code, and these two copies are kept in synchronization by Eclipse. The advantage of this approach is that Eclipse is able to operate on the local copy as normal, and does not need to be concerned with network delays or other issues. No special changes to the project infrastructure are required, since the project just looks like a normal local project. The remote copy of the code is maintained in order to be able to build the application in the environment present on the target system without needing to copy the entire source tree each time. This allows any native compilers or libraries that are present to be utilized without the need for this environment to be replicated on the local machine.

The three different project types are shown below.

Project types.png

In the local project, the primary Eclipse services, such as editing, indexing, searching, navigating, building etc. operate directly on the local project, which is located on the local filesystem of the machine running Eclipse. For remote projects, these services are proxied by an agent running on the remote machine, which must provide remote equivalents of the services Eclipse uses locally. Because the index, search, and navigation services tend to be very language specific, a different agent is required for each language that is to be supported. Currently an agent is only available for C and C++. In the case of synchronized projects, editing, indexing, etc. operate on the local copy of the project. Only the project build needs to be run on the target machine. Because this service is more generic than the language services, it is available for more languages (currently C, C++, and Fortran). To support other languages, such as python or Java, a remote version of their builders would also need to be provided. This is a much simpler task than adding services for a different language.

Design

A number of principles underpin the design of the synchronization framework. These provide goals that, although they may not be met initially, the implementation can work towards in future revisions. These principles are as follows:

  • Synchronized projects should not interfere with existing project natures. i.e. any kind of project should be synchronizable. While this goal is desirable, the current implementation only supports synchronization of CDT projects (C, C++, UPC, and Fortran) for a number of reasons that will be discussed in more detail below. Our plan is to eventually support any project nature, however.
  • The use of synchronized projects should be transparent to the user. This is largely the case for most user interface operations from within Eclipse. However, the project is ultimately located on a remote machine, so there is some degree of configuration that is required to set this up. Also, building the project occurs remotely, so the user generally needs to be aware that this is occurring.
  • Synchronized projects should be independent of Team support. Although there is a temptation to use synchronization for sharing project code, synchronized support is really orthogonal to Team support since it does not provide the same richness of features of revision control systems. Synchronization is primarily for keeping two copies of code in sync. In the current implementation, synchronized projects can also be shared with any of the Team providers that are available in Eclipse.

Synchronization Service

The synchronization framework is designed to be extensible, so that different synchronization providers can be provided to suit different environments. This is achieved by adding a new service called org.eclipse.ptp.rdt.sync.core.SyncService to the services framework provided by PTP. To add a new synchronization provider, a plugin must supply a class that implements the ISyncServiceProvider interface, then registers this class using the org.eclipse.ptp.services.core.providers extension point. The services framework will then manage loading the class at the correct time, persisting data, etc.

APIs

The ISyncServiceProvider provides the following methods:

public String getLocation() 
Get the build location specified by this sync service provider.
public IRemoteConnection getRemoteConnection() 
Get the remote connection used by this sync service provider.
public void synchronize(IProject, BuildScenario, IResourceDelta, SyncFileFilter, IProgressMonitor, EnumSet<SyncFlag>) 
Synchronize a project (represented by the IProject object) using the BuildScenario and filters specified by SyncFileFilter. If an IResourceDelta is supplied, then only resources in the delta will be synchronized. The SyncFlags control the behavior of the synchronization.
public Set<IPath> getMergeConflictFiles(IProject project, BuildScenario buildScenario) 
Get the current list of merge-conflicted files for the project and build scenario
public String[] getMergeConflictParts(IProject project, BuildScenario buildScenario, IFile file) 
Get the three parts of the merge-conflicted file (left, right, and ancestor, respectively)
public void setMergeAsResolved(IProject project, BuildScenario buildScenario, IPath[] paths) 
Set the given file paths as resolved (merge conflict does not exist)
public void checkout(IProject project, BuildScenario buildScenario, IPath[] paths) 
Replace the current contents of the given paths with the previous versions in the repository
public void checkoutRemoteCopy(IProject project, BuildScenario buildScenario, IPath[] paths) 
Replace the current contents of the given paths with the current local copies of the remote (not necessarily the same as what is on the remote site). This is useful in merge-conflict resolution.
public void close(IProject project) 
Close any resources that were open by the sync provider for the given project. Resources not open by the provider should not be touched. This is called, for example, when a project is about to be deleted.

User Interface

The synchronization user interface is provided using the context menu on a project, as shown below.

Context menu.png

The "Synchronization" menu provides the following options and commands:

Auto-Sync 
Enable/disable automatic synchronization for all projects (global option). If enabled, synchronization will take place when a resource is modified, prior to a build, and immediately after a build. If disabled, synchronization will only happen if the user selects one of the synchronization actions.
Project Auto-Sync Settings 
Sets the auto synchronization settings for the current project. If set to Sync-Active only the active configuration will be synchronized. If set to Sync-All, all configurations will be synchronized in sequence. If set to Sync-None the no configurations will be synchronized. This is the same as disabling Auto-Sync, but for a single project only.
Sync Active Now 
This command will immediately synchronize using the active configuration of the current project.
Sync All Now 
This command will immediately synchronize all configurations of the current project.
Filter... 
Open the synchronization filter dialog to configure filters for this project. Filtering is described in more detail in Filtering.

Project Nature

When a synchronized project is created, or an existing project is converted to synchronized, a remoteSyncNature is added to the project configuration. Only projects with this nature will be recognized by the synchronization framework. Projects that have this nature are decorated in the Project Explorer view to indicate that they are synchronized.

Synchronization Initiation

The synchronization framework registers a resource change listener for all resources in the workspace. Synchronization will be initiated for any resource delta that is of type IResourceDelta.CHANGED and after an event of type IResourceChangeEvent.POST_BUILD. The first synchronization will ensure that any resources that have been added, modified, or deleted in the local workspace will be reflected on the target system. The second synchronization will ensure that any artifacts that are generated as a result of the build will be copied to the local workspace. Only builds that were started manually will result in a synchronization, however, since automatic builds will occur after any resource change.

In addition to synchronizing on a resource change, projects will also be synchronized prior to a build. For CDT projects, the framework registers a remote builder using the org.eclipse.cdt.managedbuilder.core.buildDefinitions extension point, and adds this builder to the properties for the project. When the project is built, the ICommandLauncher#execute() method is invoked by the CDT managed build framework. PTP provides an implementation of ICommandLauncher called SyncCommandLauncher that will first initiate a synchronization, then issue the appropriate remote commands to build the project.

Multiple Hosts

Synchronization to multiple hosts is supported using the BuildScenario class. An object of this class is passed to the ISyncServiceProvider#synchronize() method along with the project reference. A BuildScenario encapsulates the connection and location information for the project on the remote target system. By maintaining multiple BuildScenarios, it is possible to perform synchronization to multiple systems.

For CDT projects, the BuildScenario information is stored in the project build configuration (IConfiguration interface). The framework provides the BuildConfigurationManager class for managing the interface between the synchronization framework and CDT's build configurations.

CDT provides the notion of an "active" build configuration, so the synchronization framework uses this as the default configuration when synchronizing the project. The user interface also provides a means of synchronizing all build configurations, which will cause the project to be synchronized with each target system that has been configured.

Multi sync.png

In the above diagram, a project is being synchronized to three remote hosts, A, B, and C. The "active" configuration is currently set to host A, so when a build or synchronize is performed, it will automatically use that host.The user can override this by use the "Build All" or "Synchronize All Now" menus.

Wizards

Synchronized projects are created using one of two available wizards. A new synchronized project can be created from scratch, or from an existing remote project, using the Synchronized Project wizard. An existing local project can also be converted to a synchronized project (and hence synchronized to a remote system) using the Convert To Synchronized Project wizard.

Synchronized Project Wizard

This wizard is used to create a new synchronized project from scratch, or to synchronize with an existing remote project. It comes in two flavors, one for creating C/C++ projects, and one for creating Fortran projects. The only difference between these is that the latter wizard adds a Fortran nature to the project, so should be used if the project is likely to contain any Fortran code. The user interface is shown below.

New wizard.png

The wizard is similar to the normal C Project or C++ Project wizards in that it allows the user to specify a project name, location, select the project type, and choose the toolchain. In addition to these however, the wizard allows the user to select a remote location for the project, which is the location that will be used to synchronize the remote files, and a remote toolchain that specifies the toolchain that will be used on the remote machine. If the remote project location already contains resources, then these will be synchronized with the local project immediately upon completion of the wizard.

Convert To Synchronized Project Wizard

As its name implies, this wizard is used to convert an existing C, C++, or Fortran project to be synchronized, which requires adding a remote location and remote toolchain to the project. When the wizard is first invoked, it will scan the workspace for any non-synchronized CDT projects. The user is then able to select the projects for conversion from a list, and once a remote location is chosen, the project will be converted. This process duplicates the selected configurations and adds the remote location to them. If a different toolchain needs to be selected for the remote configurations, the user must manually edit the build configuration for each remote configuration. The user interface for this wizard is shown below.

Convert wizard.png

Filtering

Being able to specify which files are synchronized is essential, especially for projects that contain large numbers of object files or large data files that are not necessary for application development. Filtering is provided on a per-project basis, and can be used to specify exactly which resources are included or excluded from the synchronization. Default filters can also be set in the Eclipse settings, and these are inherited by a synchronized project when it is created. By default, the following resources are excluded: .ptp-sync, .settings, .cproject, and .project.

APIs

Resource filtering is provided using the SyncFileFilter class which is passed to the ISyncProvider#synchronize() method, which maintains a list of patterns (which extend the abstract base class ResourcePattern) that are to be included in the the synchronization and list that are to be excluded from the synchronization.

In the current implementation, two types of filter patterns are available:

PathResourceMatcher 
This filter tests resources against a specific directory path.
RegexPatternMatcher 
This filter tests resources against a regular expression.

User Interface

Filtering can be configured when creating a synchronized project or converting a project to use synchronization. Filters can also be configured at any time using the synchronization context menu on the project. The following user interface is used for configuration filtering on a project.

Filter config.png

The File View area is used to include or exclude resources directly (using the checkbox next to the resource), and will also show which files are being included or excluded based on the patterns. The Pattern View shows the currently defined patterns and allows the pattern ordering to be altered. Patterns are applied in order from top to bottom. A new path or regex pattern can be added by entering the information in the appropriate text field and selecting either the Exclude or Include buttons as required.

Off-line Operation

One of the advantages of synchronized projects over remote projects is the ability to operate without a network connection. Off-line operation is automatically managed by the use of asynchronous synchronize operations. If a connection to the target system is unavailable, the operation will be queued in order until network connectivity is restored, at which time the operations will be performed. The user does not need to take any action for this automatic behavior to be enabled.

A caveat to off-line operation is that building remotely while off-line is not possible. If the user attempts to build while off-line, then the build will fail and any subsequent synchronization operations will be discarded. [verify this behavior]

Scanner Discovery & Include Files

Many of the advanced features of CDT and Photran require indexing/parsing the source code. When a project is being built remotely, the source code presented to the user should reflect the environment on the remote system rather than the local system. The main mechanisms that distinguish a remote environment from the local environment are the macros that are predefined by the compiler and the system include files that are included in the source code.

Note that this support is independent of remote synchronization (although may use some remote synchronization functionality to achieve it). A remotely synchronized project can still use a purely local environment without requiring any additional functionality.

To present an accurate reflection of the remote environment, system include files need to be fetched from the remote system for the preprocessor and indexer. This requires changes to the preprocessor and other parts of CDT/Photran in order to obtain the header file from the correct remote system rather than from the local system. To avoid performance issues, header files should also be cached locally where possible, but this must be an option as licensing issues may prevent it on some systems.

Compiler (and makefile) defined macros play an important part in determining which header files will be included as well as which parts of the code will be enabled or disabled. CDT attempts to determine these macros using a process known as scanner discovery. This involves running commands on the target system to determine the macros that are defined. This process is inherently complex because every system has different compilers with different options for determining this information. RDT has already provided some remote scanner discovery functionality, so we plan to reuse this for synchronized projects.

Synchronization Provider Implementations

Currently the only mature synchronization provider uses the Git protocol to manage synchronization. Some work has been undertaken to develop a provider based on Rsync, but to date this has not been completed. The Git provider uses the JGit feature to provide a Java implementation of Git for Eclipse. Git also has the advantage of being very fast, even for a large number of small commits.

It is outside the scope of this document to describe the details of the Git implementation.

Support for Non-CDT Projects

The current implementation of synchronized projects relies on the build configuration properties of CDT projects for a number of reasons. Project building and synchronization are closely related, since the purpose of synchronizing a project is generally to support remote building. CDT's build configurations provide a simple mechanism for supporting synchronization to multiple hosts, since each host can be associated with a build configuration, and the configuration augmented to include the location of the remote project. The "active" synchronization host then automatically corresponds to the "active" build configuration. Another advantage of using CDT's build configurations is that the configuration information is stored with the project, so moving the project to a different workspace automatically preserves the synchronization information.

In order to support the synchronization of other projects, such as Java or Python, the synchronization configuration information needs to be maintained in a different manner. This could be either using a project-specific location (such as CDT's build configurations) or as generic information in the project properties. In addition, building these projects remotely requires a different remote builder implementation, since they are unlikely to use Makefiles as their primary build mechanism.

Back to the top