Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: first draft of Infrastructure API and related models #407

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

deepak-swirlds
Copy link
Contributor

Description

This pull request changes the following:

  • First Draft of the Infrastructure API
  • Any supporting model classes

Related Issues

Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
@leninmehedy
Copy link
Member

leninmehedy commented Oct 17, 2023

@deepak-swirlds I remember you wanted to close this PR and start creating smaller ones. Is that still the plan? If yes, please close this PR.

Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
@nathanklick nathanklick changed the title Add first draft of Infrastructure API and related models feat: Add first draft of Infrastructure API and related models Oct 24, 2023
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
…tion-api

Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Copy link

github-actions bot commented Nov 3, 2023

Unit Test Results

  26 files  ±0    26 suites  ±0   52s ⏱️ ±0s
109 tests ±0  105 ✔️ ±0  4 💤 ±0  0 ±0 
110 runs  ±0  106 ✔️ ±0  4 💤 ±0  0 ±0 

Results for commit 3f5677a. ± Comparison against base commit af42af8.

♻️ This comment has been updated with latest results.

Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>

import com.hedera.fullstack.infrastructure.api.model.AbstractWorkload;

public class EthBridge extends AbstractWorkload<EthBridge> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not very clear what EthBridge is. Probably a different or longer name would be better. Also needs a doc block and also for other Workload types.

import com.hedera.fullstack.base.api.version.SemanticVersion;
import com.hedera.fullstack.configuration.model.NetworkDeploymentConfiguration;

public interface ResourceUtils {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this class will evolve a bit more as we discover the needs. There could be utility package with separate responsibilities instead of a single utility class

Copy link
Member

@leninmehedy leninmehedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Let's merge this first version and start focusing on polishing smaller parts one at a time. It is difficult to get it perfect in one go... This is already a too big PR.

@leninmehedy leninmehedy changed the title feat: Add first draft of Infrastructure API and related models feat: first draft of Infrastructure API and related models Nov 5, 2023
nathanklick and others added 7 commits November 6, 2023 20:29
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Signed-off-by: Deepak Mishra <deepak@swirldslabs.com>
Copy link

sonarcloud bot commented Nov 9, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 18 Code Smells

0.0% 0.0% Coverage
1.7% 1.7% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

* of the specified type is hosted on this cluster.
* @throws IllegalArgumentException if workloadType is null
*/
<T extends Workload> T findWorkloadByType(Class<T> workloadType) throws IllegalArgumentException;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 101).

The code provided has a line that exceeds the 80-character limit, which is a common style guideline to ensure readability and maintainability of the code. Long lines can be harder to read, especially in environments where screen real estate is limited, such as in code reviews or when using split-screen editors.

To fix this issue, you can split the method signature into multiple lines. This will make the code more readable and compliant with the 80-character limit rule. Here's an example of how you could reformat the method signature:

Suggested change
<T extends Workload> T findWorkloadByType(Class<T> workloadType) throws IllegalArgumentException;
<T extends Workload> T findWorkloadByType(Class<T> workloadType)
throws IllegalArgumentException;

By breaking the line after the generic type declaration, you ensure that each line is within the 80-character limit, while still keeping the code clear and understandable.


This comment was generated by an experimental AI tool.

* @param deploymentNetworkDeploymentConfiguration
* the deployment network deployment configuration
*/
default void configure(NetworkDeploymentConfiguration deploymentNetworkDeploymentConfiguration) {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 102).

The code provided contains a method signature that exceeds the 80-character line length limit enforced by the Checkstyle linter. This is a common code style guideline meant to improve readability and maintainability of the code, especially on smaller screens or when viewing multiple files side by side.

To fix this issue, you can break the line into multiple lines. Here's an example of how you might format the method to comply with the 80-character limit:

default void configure(
    NetworkDeploymentConfiguration deploymentNetworkDeploymentConfiguration) {}

By breaking the line after the configure(, you ensure that each line stays within the 80-character limit. You might also consider renaming the parameter to a shorter name if it's still too long, or if the context allows for it without losing clarity.

Here's the code suggestion with a shorter parameter name:

Suggested change
default void configure(NetworkDeploymentConfiguration deploymentNetworkDeploymentConfiguration) {}
default void configure(NetworkDeploymentConfig config) {}

Remember to update the Javadoc comments accordingly if you change the parameter name.


This comment was generated by an experimental AI tool.

}

/**
* Creates a new {@link WorkloadReplica} with the given components and index.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 81).

The code provided includes a comment line that exceeds the 80-character limit imposed by the Checkstyle rule for maximum line length. This rule is often used to ensure that code is easily readable without the need to scroll horizontally, which can be particularly important when reviewing code on platforms with limited screen space or when printing code on paper.

To fix this issue, you can break the comment into multiple lines so that no single line exceeds the 80-character limit. Here's how you can reformat the comment:

Suggested change
* Creates a new {@link WorkloadReplica} with the given components and index.
/**
* Creates a new {@link WorkloadReplica} with the given components
* and index.
* @param components the {@link Component}s of this Workload Replica
* @param index the index of this Workload Replica
*/

By splitting the comment into two lines, each line now adheres to the 80-character limit, resolving the Checkstyle warning.


This comment was generated by an experimental AI tool.

* <p>Since this method returns a {@code Future} any exceptions thrown during the asynchronous execution
* will be wrapped in a {@link java.util.concurrent.ExecutionException}
* </p>
* @param hederaNetwork {@link NetworkDeploymentConfiguration} object containing all the configuration needed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 113).

The code provided contains a Javadoc comment with a line exceeding the 80-character limit, which is a common code style guideline to ensure readability and maintainability of the code. Long lines can be difficult to read, especially in environments with limited screen space or when viewing diffs in version control systems.

To fix the issue, you can break the long line into multiple lines, ensuring that each line does not exceed the 80-character limit. Here's an updated version of the Javadoc comment with the line in question wrapped to meet the 80-character limit:

Suggested change
* @param hederaNetwork {@link NetworkDeploymentConfiguration} object containing all the configuration needed
/**
* <p>Creates the {@link NetworkDeployment} based on the
* {@link NetworkDeploymentConfiguration} provided. This is a long-running
* process.</p>
* <p>Note: the {@link NetworkDeployment} can be spread across multiple
* clusters and cloud providers.</p>
* <p>Since this method returns a {@code Future} any exceptions thrown
* during the asynchronous execution will be wrapped in a
* {@link java.util.concurrent.ExecutionException}</p>
* @param hederaNetwork {@link NetworkDeploymentConfiguration} object
* containing all the configuration needed to create
* the {@link NetworkDeployment}
* @return a {@link NetworkDeployment} object representing the
* {@link NetworkDeployment} created
* @throws InvalidConfigurationException if the
* {@link NetworkDeploymentConfiguration} is invalid
* @throws InsufficientClusterResourcesException if there are not enough
* resources in the cluster to create the {@link NetworkDeployment}
* @throws InfrastructureException if there is an infrastructure related
* exception, the underlying cause will be captured in the nested
* exception.
* @throws NullPointerException if the {@code hederaNetwork} configuration
* is {@code null}.
*/
Future<NetworkDeployment> createNetworkDeploymentAsync(
NetworkDeploymentConfiguration hederaNetwork)
throws InvalidConfigurationException, InsufficientClusterResourcesException,
InfrastructureException;

This suggestion wraps the long lines and aligns the wrapped lines appropriately, making the comment more readable while adhering to the 80-character limit.


This comment was generated by an experimental AI tool.

* <strong> About NetworkDeployments </strong>
* <p>
* A {@link NetworkDeployment} represents all the workloads and their components needed for a Hedera ecosystem. <br/>
* Upon instantiation, the {@link NetworkDeployment} object can interact with its workloads and components directly

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 115).

The issue identified by Checkstyle is that the line of code exceeds the maximum preferred line length of 80 characters, which is a common code style guideline to improve readability. Long lines of code can be difficult to read, especially in environments with limited screen space or when viewing multiple files side by side.

To fix this issue, you can break the long comment line into two or more lines, ensuring that each line does not exceed 80 characters. Here's how you can modify the comment:

Suggested change
* Upon instantiation, the {@link NetworkDeployment} object can interact with its workloads and components directly
* Upon instantiation, the {@link NetworkDeployment} object can interact with
* its workloads and components directly and does not need {@link InfrastructureManager}.

By splitting the comment into two lines, each line now adheres to the 80-character limit, which should resolve the Checkstyle warning for line length.


This comment was generated by an experimental AI tool.


public class JSONRPCRelay extends AbstractWorkload<JSONRPCRelay> {

public JSONRPCRelay(List<WorkloadReplica<JSONRPCRelay>> workloadReplicas, Cluster cluster) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 96).

The code style issue reported by Checkstyle indicates that the line of code exceeds the maximum length allowed by the coding standards being used, which in this case is 80 characters. Long lines of code can be harder to read and maintain, especially when viewing code in editors with limited horizontal space or when printing code on paper.

To fix this issue, you can break the line into multiple lines. This can be done by splitting the declaration at a logical point, such as after a comma in the parameter list, and indenting the subsequent lines to improve readability.

Here's a suggestion to reformat the constructor to comply with the 80-character line length limit:

Suggested change
public JSONRPCRelay(List<WorkloadReplica<JSONRPCRelay>> workloadReplicas, Cluster cluster) {
public class JSONRPCRelay extends AbstractWorkload<JSONRPCRelay> {
public JSONRPCRelay(
List<WorkloadReplica<JSONRPCRelay>> workloadReplicas,
Cluster cluster
) {
super(workloadReplicas, cluster);
}
}

This change splits the constructor parameters across multiple lines, each line now being within the 80-character limit. The indentation level for the split lines should be consistent with your project's style guide.


This comment was generated by an experimental AI tool.


/**
* Retrieves the platform configuration builder of this {@link NetworkDeployment}.
* @return the platform configuration builder of the {@link NetworkDeployment}.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 84).

The issue highlighted by Checkstyle is that one of the comment lines exceeds the maximum length of 80 characters, which is a common code style guideline to ensure readability across various environments and tools.

To fix this issue, you can break the comment line into two lines, ensuring that each line does not exceed 80 characters. Here's the fixed comment block:

Suggested change
* @return the platform configuration builder of the {@link NetworkDeployment}.
/**
* Retrieves the platform configuration builder of this {@link NetworkDeployment}.
* @return the platform configuration builder.
*/

This change keeps the description concise and within the character limit, while still providing the necessary information. If more detail is needed, you can expand the comment in a way that adheres to the line length limit.


This comment was generated by an experimental AI tool.


/**
* This is a synchronous version of {@link #createNetworkDeploymentAsync(NetworkDeploymentConfiguration)}
* @throws InvalidConfigurationException if the {@link NetworkDeploymentConfiguration} is invalid

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 101).

The code provided includes a comment line that exceeds the 80-character limit preferred by the Checkstyle linter for Java code. This is a common code style guideline to ensure readability and maintainability. Lines that are too long can be hard to read, especially in environments with limited screen space or when viewing diffs in version control systems.

To fix this issue, you can break the comment line into two or more lines, ensuring that each line does not exceed the 80-character limit. Here's how you could reformat the problematic comment line:

Suggested change
* @throws InvalidConfigurationException if the {@link NetworkDeploymentConfiguration} is invalid
* @throws InvalidConfigurationException if the
* {@link NetworkDeploymentConfiguration} is invalid

This comment was generated by an experimental AI tool.


List<LogEntry> getLogs(int tailLines);

List<LogEntry> getLogs(LocalDateTime startDateTime, LocalDateTime endDateTime);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 83).

The code provided has a line that exceeds the 80-character limit, which is a common code style guideline intended to improve readability and maintainability. Long lines can be harder to read, especially in environments with limited screen space or when working with side-by-side code comparisons.

To adhere to the 80-character limit, you can break the line into multiple lines. For method declarations, you can break the line after a comma that separates the method parameters. Here's how you can refactor the method signature to conform to this guideline:

Suggested change
List<LogEntry> getLogs(LocalDateTime startDateTime, LocalDateTime endDateTime);
List<LogEntry> getLogs(LocalDateTime startDateTime,
LocalDateTime endDateTime);

With this change, the method signature is split into two lines, each within the 80-character limit, while maintaining readability and adhering to the code style guideline.


This comment was generated by an experimental AI tool.

throws InvalidConfigurationException, InsufficientClusterResourcesException, InfrastructureException;

/**
* List all the {@link NetworkDeployment} instances created by this JVM process.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 84).

The code provided contains JavaDoc comments that are not adhering to the line length limit enforced by Checkstyle. The line length limit is often set to improve readability and maintainability of the code. In this case, the line exceeds the 80 characters limit by 4 characters.

To fix this issue, you can reformat the JavaDoc comment to ensure that no line exceeds 80 characters. You can do this by breaking the sentence into multiple lines. Below is the problematic line reformatted to comply with the 80-character limit:

Suggested change
* List all the {@link NetworkDeployment} instances created by this JVM process.
* List all the {@link NetworkDeployment} instances created by this JVM
* process.

By breaking the sentence into two lines, each line now adheres to the 80-character limit, and the JavaDoc comment remains clear and understandable.


This comment was generated by an experimental AI tool.


/**
* <p>Thrown when the {@link com.hedera.fullstack.configuration.infrastructure.NetworkDeploymentConfiguration} is invalid.</p>
* <p>This can happen if the network deployment configuration has failed validation even before the deployment has started.</p>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 127).

The code provided includes a comment line that exceeds the maximum line length of 80 characters as per the coding standards enforced by the Checkstyle linter. Long lines can be harder to read, especially in environments with limited screen space, and can lead to horizontal scrolling, which is generally discouraged in code style guidelines.

To fix this issue, you can break the long comment line into multiple lines, ensuring that each line does not exceed 80 characters. This will improve readability and comply with the Checkstyle rule for maximum line length.

Here's how you can refactor the comment to meet the Checkstyle requirements:

Suggested change
* <p>This can happen if the network deployment configuration has failed validation even before the deployment has started.</p>
/**
* <p>Thrown when the {@link com.hedera.fullstack.configuration.infrastructure.NetworkDeploymentConfiguration} is invalid.</p>
* <p>This can happen if the network deployment configuration has failed
* validation even before the deployment has started.</p>
*/

By splitting the long comment into two lines, each line is now within the 80-character limit, and the issue should be resolved.


This comment was generated by an experimental AI tool.

* @throws InfrastructureException if there is an infrastructure related exception during creation of the {@link NetworkDeployment}.
* The underlying cause will be captured in the nested exception.
* If a deployment has already started, it may leave behind partially created resources.
* These partial resources can be cleaned by {@link NetworkDeployment#delete()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 82).

The code provided includes a comment line that exceeds the maximum line length of 80 characters as per the code style enforced by Checkstyle. To adhere to this rule, the comment should be wrapped to ensure that no line goes beyond 80 characters.

To fix this, you can break the long comment line into two lines. Here's how you can modify the comment:

Suggested change
* These partial resources can be cleaned by {@link NetworkDeployment#delete()
* These partial resources can be cleaned by {@link NetworkDeployment#delete()}

The fixed comment block would look like this:

/**
 * This is a synchronous version of {@link #createNetworkDeploymentAsync(NetworkDeploymentConfiguration)}
 * @throws InvalidConfigurationException if the {@link NetworkDeploymentConfiguration} is invalid
 * @throws InsufficientClusterResourcesException if there are not enough resources in the cluster to create the {@link NetworkDeployment}
 * @throws InfrastructureException if there is an infrastructure related exception during creation of the {@link NetworkDeployment}.
 * The underlying cause will be captured in the nested exception.
 * If a deployment has already started, it may leave behind partially created resources.
 * These partial resources can be cleaned by {@link NetworkDeployment#delete()}
 */

By breaking the comment into two lines, each line stays within the 80-character limit, which complies with the Checkstyle code style rules.


This comment was generated by an experimental AI tool.

/**
*
* <p>Thrown when an infrastructure-related exception occurs at the lower level of the implementation.</p>
* <p>A nested exception (cause) should be provided to capture the root cause of the exception.</p>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 99).

The code provided includes a comment line that exceeds the 80 character limit per line, which is a common code style guideline to ensure readability and maintainability of code. Long lines can be difficult to read, especially on smaller screens or when viewing multiple files side by side.

To fix this issue, you can break the long comment line into two or more shorter lines, ensuring that each line does not exceed 80 characters. Here's how you can modify the comment:

Suggested change
* <p>A nested exception (cause) should be provided to capture the root cause of the exception.</p>
* <p>A nested exception (cause) should be provided to capture the root
* cause of the exception.</p>

By splitting the comment into two lines, each line is now within the 80-character limit, adhering to the Checkstyle rule for line length.


This comment was generated by an experimental AI tool.


public class Minio extends AbstractWorkload<Minio> {

public Minio(List<WorkloadReplica<Minio>> workloadReplicas, Cluster cluster) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 82).

The code provided does not adhere to the 80-character line length limit that is commonly enforced in Java coding standards to improve readability. This rule is particularly useful when viewing code on devices with smaller screens or when printing code on paper.

To fix this issue, you can break the line into multiple lines. This can be done by splitting the constructor parameters across multiple lines. Here is how you can refactor the constructor to comply with the 80-character limit:

Suggested change
public Minio(List<WorkloadReplica<Minio>> workloadReplicas, Cluster cluster) {
public Minio(
List<WorkloadReplica<Minio>> workloadReplicas,
Cluster cluster
) {
super(workloadReplicas, cluster);
}

By splitting the parameters onto separate lines, the code becomes easier to read and adheres to the Checkstyle rule for line length.


This comment was generated by an experimental AI tool.

/**
* Searches for a workload of the specified type that is hosted on this cluster.
* @param <T> the type parameter of the workload to search for
* @param workloadType the {@link Class} object corresponding to the workload type

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Codacy found a minor Code Style issue: Line is longer than 80 characters (found 86).

The issue raised by Checkstyle is that the line in the Javadoc comment exceeds the maximum allowed length of 80 characters. This is a common code style guideline to ensure that code is easily readable without the need for horizontal scrolling, which can be particularly important when reviewing code on devices with smaller screens or in tools that limit the width of the code view.

To fix this issue, you can break the comment into two lines so that each line stays within the 80-character limit. Here's how you can adjust the Javadoc comment:

Suggested change
* @param workloadType the {@link Class} object corresponding to the workload type
* @param workloadType the {@link Class} object of the workload type

And the rest of the comment can be wrapped to the next line:

Suggested change
* @param workloadType the {@link Class} object corresponding to the workload type
* to search for

After applying the suggested changes, the Javadoc will look like this:

    /**
     * Searches for a workload of the specified type that is hosted on this cluster.
     * @param <T> the type parameter of the workload to search for
     * @param workloadType the {@link Class} object of the workload type
     *         to search for
     * @return an instance of the specified {@link Workload} type if found, or null if no workload
     *         of the specified type is hosted on this cluster.
     * @throws IllegalArgumentException if workloadType is null
     */
    <T extends Workload> T findWorkloadByType(Class<T> workloadType) throws IllegalArgumentException;
}

This ensures that the comment is within the 80-character limit and maintains the readability of the code.


This comment was generated by an experimental AI tool.

@leninmehedy leninmehedy reopened this Dec 11, 2023
Copy link

sonarcloud bot commented Dec 11, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 18 Code Smells

0.0% 0.0% Coverage
1.7% 1.7% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

first pass: create mock interface and classes for infrastructure API
4 participants