<div style="text-align:center">
    <img src="https://www.gitlink.org.cn/images/avatars/Organization/123822?t=1689062058" alt="PCM"  style="float:center" />
</div>
<p align="center">  
  <a href="https://www.gitlink.org.cn/JointCloud/pcm-coordinator/tree/master/docs">Docs</a> |  
  <a href="https://www.gitlink.org.cn/JointCloud/pcm-coordinator/tree/master/docs">简体中文</a> |   
  <a href="https://www.gitlink.org.cn/JointCloud/pcm-coordinator/milestones">Milestones</a>  
</p>  

## What is Jointcloud and PCM

Jointcloud Cooperation Environment (JCCE) comprises Distributed Cloud Trading, Distributed Cloud Community, Distributed Cloud Supervision, and a Blockchain-based Distributed Accounting System. JCCE, with its supporting technologies related to information and value exchange, facilitates breaking the information asymmetry among participants in cloud collaboration. It creates a win-win opportunity for all involved parties and provides robust support for innovative business models in the cloud collaboration computing environment.

The vision of the Peer Cooperation Mechanism (PCM) is to build a set of collaboration mechanisms in the cloud environment where all service providers and demand-side entities can autonomously participate, achieve peer-to-peer transactions, and establish efficient connections and invocations in a non-intrusive manner. PCM focuses more on collaboration among clouds rather than individual clouds themselves.

PCM is built upon a standardized software-defined framework. Cloud service providers with physical cloud resources can autonomously define PCM rule frameworks. Other entities adhering to these rule frameworks can then participate in collaborative transactions. Subsequently, tailored virtual private clouds can be created for domain-specific applications, meeting the diverse requirements of various cloud participants, such as central, edge, and terminal infrastructure, enabling them to directly participate in collaboration and transactions.

## Real-world Issues Addressed by PCM:

-   **Performance Improvement**   
Developers in the cloud collaboration environment experience performance enhancement upon joining the PCM framework. They can generate code for the internal functionality structure and most specification definitions using descriptive language, allowing them to focus on business logic development without concerning themselves with underlying management functions. The framework offers features such as microservices management, multi-language code generation, and model bridging, reducing coding workload and entry barriers while improving efficiency.


-   **Platform Lock-in Resolution**   
The PCM effectively addresses platform lock-in issues through multi-cloud adaptation, standardized interfaces, and abstraction layers. This enables cross-platform operations, deployment, and interaction. Standardized interfaces simplify the work for developers, lowering the risk of platform lock-in.


-   **Reduced Code Development Complexity**   
The PCM development framework lowers the complexity of development by providing structured development patterns, ready-made components, and documentation support. Developers of different skill levels can collaborate more fairly. The framework can save approximately 50% of development time, with junior programmers completing tasks that originally required one person-month in about 15 person-days. Features such as automatic generation tools, code templates, and component reuse allow developers to focus more on business logic implementation. There is no need for additional training of advanced developers, saving time, and reducing labor costs while improving the return on investment.


-   **Reduced Code Development Workload**   
The PCM framework offers automation features and code generation tools, reducing manual code writing and improving development speed and code quality. With the framework's auto-generation tools, over half of the code is generated, achieving a low code rate of approximately 63%. Developers primarily work on writing descriptive language files to generate the basic structure and then adjust and write logic functions. This enables teams to deliver products more quickly, iterate based on business optimization and user feedback, and be more agile.


## Architecture
The Coordinator is the core component of the framework, providing heterogeneous abstraction for different Participant-side technology stacks. The framework, oriented towards the user side, primarily involves two major functionalities: resource changes (task submission) and centralized display. After task submission, PCM achieves dynamic task flow through a scheduling center deployed on cloud computing, intelligent computing, and supercomputing clouds. In the centralized display section, PCM mainly collects and aggregates information about resources and tasks from multiple Participant services through Tracker and actively reported by the Participant side. It provides users with a standardized unified interface. Users can view the information provided by PCM on the frontend page or directly access data through the interface.

![PCM架构](docs/images/arch-eng.png)
## PCM deploy

The development environment for PCM requires the installation of Go version 1.18 or above. Please refer to the following instructions to locally start the Kubernetes-related services.

The command to fetch the project is as follows:
```bash
 git clone https://gitlink.org.cn/JointCloud/pcm-coordinator.git 
```


After executing the following command, the Kubernetes RPC service will be launched locally. For its specific functionalities, please refer to the description in the architecture design mentioned earlier.
```  bash
# get required packages  
go mod tidy  
  
# run rpc service  
go run pcm-coordinator/rpc/pcmcore.go  
```
#### coordinator-api
The template for the configuration content of the API service is as follows, where the config information for each Participant (P-side) can be configured as needed based on the actual situation.
```  bash
Name: pcm.core.api  
Host: 0.0.0.0  
Port: 8999  
  
DB:  
  DataSource: username:password@(x.x.x.x:3306)/pcm?parseTime=true  Redis:  
  Host: x.x.x.x:portnumber  Pass: password  
  
# k8s rpc  
K8sNativeConf:  
  Endpoints:    - 127.0.0.1:2003  NonBlock: true  
#slurm rpc  
THRpcConf:  
  Endpoints:    - 127.0.0.1:2007NonBlock: true  
  
#modelarts rpc  
ModelArtsRpcConf:  
  Endpoints:    - 127.0.0.1:2002NonBlock: true  
```
After executing the following command, the Kubernetes API service will be launched locally. Once the service is started, users can make HTTP requests to its interfaces for various functional calls.
```  bash
# get required packages  
go mod tidy  
  
# run rpc service  
go run pcm-coordinator/api/pcm.go  
```

## Upcoming Plans

-   Pluginization of Scheduling Algorithms and Definition of Basic Resource Templates.
-   Fundamental Definition of Resource Operation Types.
-   Rapid Development Mode.
-   Implementation of First-level Scheduling.

## Join＆Contribute
We look forward to your opinions and contributions. Welcome all friends to provide corrections and improvements to the project, collectively building an efficient and stable cloud collaboration mechanism.