/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/content/ContentServerService.java

https://github.com/ccrouch/rhq · Java · 219 lines · 49 code · 16 blank · 154 comment · 0 complexity · 476a147dcbc12d1fc004ab202858a632 MD5 · raw file

  1. /*
  2. * RHQ Management Platform
  3. * Copyright (C) 2005-2008 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License, version 2, as
  8. * published by the Free Software Foundation, and/or the GNU Lesser
  9. * General Public License, version 2.1, also as published by the Free
  10. * Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License and the GNU Lesser General Public License
  16. * for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * and the GNU Lesser General Public License along with this program;
  20. * if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. */
  23. package org.rhq.core.clientapi.server.content;
  24. import java.io.InputStream;
  25. import java.io.OutputStream;
  26. import java.util.Set;
  27. import org.rhq.core.communications.command.annotation.Asynchronous;
  28. import org.rhq.core.communications.command.annotation.LimitedConcurrency;
  29. import org.rhq.core.communications.command.annotation.Timeout;
  30. import org.rhq.core.domain.content.Repo;
  31. import org.rhq.core.domain.content.PackageDetailsKey;
  32. import org.rhq.core.domain.content.PackageVersion;
  33. import org.rhq.core.domain.content.composite.PackageVersionMetadataComposite;
  34. import org.rhq.core.clientapi.server.content.ContentDiscoveryReport;
  35. import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
  36. import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
  37. import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
  38. import org.rhq.core.domain.util.PageControl;
  39. import org.rhq.core.domain.util.PageList;
  40. /**
  41. * Server-side interface for interacting with the server's content subsystem.
  42. */
  43. public interface ContentServerService {
  44. /**
  45. * Concurrency control parameter to limit the number of content reports that are handled.
  46. */
  47. String CONCURRENCY_LIMIT_CONTENT_REPORT = "rhq.server.concurrency-limit.content-report";
  48. /**
  49. * Concurrency control setting to limit the number of packages that can be downloaded.
  50. */
  51. String CONCURRENCY_LIMIT_CONTENT_DOWNLOAD = "rhq.server.concurrency-limit.content-download";
  52. /**
  53. * Sends a set of newly discovered packages to the server. The collection of packages represents the current set of
  54. * packages deployed on the specified resource. As such, entries may be either new packages or packages that have
  55. * been returned from a previous discovery. Any packages that were known for the resource that are not in this
  56. * collection of package are considered deleted from the resource.
  57. *
  58. * @param report report containing the current set of packages installed on the resource.
  59. */
  60. @Asynchronous(guaranteedDelivery = true)
  61. @LimitedConcurrency(CONCURRENCY_LIMIT_CONTENT_REPORT)
  62. void mergeDiscoveredPackages(ContentDiscoveryReport report);
  63. /**
  64. * Informs the server that a previous request to deploy a package has completed.
  65. *
  66. * @param response indicates the original request and the result of executing it
  67. */
  68. @Asynchronous(guaranteedDelivery = true)
  69. void completeDeployPackageRequest(DeployPackagesResponse response);
  70. /**
  71. * Informs the server that a previous request to delete a package has completed.
  72. *
  73. * @param response indicates the original request and the result of executing it
  74. */
  75. @Asynchronous(guaranteedDelivery = true)
  76. void completeDeletePackageRequest(RemovePackagesResponse response);
  77. /**
  78. * Informs the server that a previous request to get a package's bits has completed.
  79. *
  80. * @param response indicates the original request and the result of executing it
  81. * @param contentStream stream of the package bits being retrieved
  82. */
  83. @Asynchronous(guaranteedDelivery = true)
  84. void completeRetrievePackageBitsRequest(ContentServiceResponse response, InputStream contentStream);
  85. /**
  86. * Informs the server that a package installation (as indicated in the specified request ID) requires dependency
  87. * packages to be installed. The server will look in its package store to make sure the correct package versions can
  88. * be found. The server will take the necessary server-side actions to ensure the integrity of the initial request
  89. * (such as attaching the dependency packages to the initial request entity). In the case of a failure, the server
  90. * should not mark the request entity as a failure; the natural workflow of a failure response coming back to the
  91. * server from the agent will take care of that. This method should return the fully populated package descriptions.
  92. * If the package was not found in the package database, it will be omitted from the returned set.
  93. *
  94. * @param requestId refers back to the request ID of the package deployment for which these dependencies
  95. * were found
  96. * @param dependencyPackages provides information on the dependency package (name, type, version, architecture);
  97. *
  98. * @return fully populated metadata on the packages known to the server for each of the specified keys; if the
  99. * server does not know about a package, it will not be present in the returned set
  100. */
  101. Set<ResourcePackageDetails> loadDependencies(int requestId, Set<PackageDetailsKey> dependencyPackages);
  102. /**
  103. * Requests that the server download and stream the bits for the specified package. If the package cannot be found,
  104. * an exception will be thrown.
  105. *
  106. * @param resourceId identifies the resource to which the bits will be installed
  107. * @param packageDetailsKey identifies the package to download
  108. * @param outputStream an output stream where the server should write the package contents. It is up to the
  109. * caller to prepare this output stream in order to write the package content to an
  110. * appropriate location.
  111. *
  112. * @return the number of bytes written to the output stream - this is the size of the package version that was
  113. * downloaded
  114. */
  115. @Timeout(45 * 60 * 1000L)
  116. @LimitedConcurrency(CONCURRENCY_LIMIT_CONTENT_DOWNLOAD)
  117. long downloadPackageBitsGivenResource(int resourceId, PackageDetailsKey packageDetailsKey, OutputStream outputStream);
  118. /**
  119. * Requests that the server download and stream the bits for the specified package. If the package cannot be found,
  120. * an exception will be thrown.
  121. *
  122. * @param resourceId identifies the resource to which the bits will be installed
  123. * @param packageDetailsKey identifies the package to download
  124. * @param outputStream an output stream where the server should write the package contents. It is up to the
  125. * caller to prepare this output stream in order to write the package content to an
  126. * appropriate location.
  127. * @param startByte the first byte (inclusive) of the byte range to retrieve and output (bytes start at
  128. * index 0)
  129. * @param endByte the last byte (inclusive) of the byte range to retrieve and output (-1 means up to EOF)
  130. * (bytes start at index 0)
  131. *
  132. * @return the number of bytes written to the output stream - this is the size of the chunk downloaded
  133. */
  134. @Timeout(45 * 60 * 1000L)
  135. @LimitedConcurrency(CONCURRENCY_LIMIT_CONTENT_DOWNLOAD)
  136. long downloadPackageBitsRangeGivenResource(int resourceId, PackageDetailsKey packageDetailsKey,
  137. OutputStream outputStream, long startByte, long endByte);
  138. /**
  139. * Downloads the package bits used to create a package used as the backing of a resource.
  140. *
  141. * @param parentResourceId identifies the parent resource under which the new resource is being created
  142. * @param resourceTypeName type of child resource being created
  143. * @param packageDetailsKey package being used to create the child resource
  144. * @param outputStream an output stream where the server should write the package contents. It is up to the
  145. * caller to prepare this output stream in order to write the package content to an
  146. * appropriate location.
  147. *
  148. * @return the number of bytes written to the output stream
  149. */
  150. @Timeout(45 * 60 * 1000L)
  151. @LimitedConcurrency(CONCURRENCY_LIMIT_CONTENT_DOWNLOAD)
  152. long downloadPackageBitsForChildResource(int parentResourceId, String resourceTypeName,
  153. PackageDetailsKey packageDetailsKey, OutputStream outputStream);
  154. /**
  155. * Requests all {@link PackageVersion#getMetadata() metadata} for all package versions that the given resource
  156. * component is subscribed to (see {@link Repo#getResources()}. The returned object has the metadata bytes that
  157. * are meaningful to the calling plugin component.
  158. *
  159. * <p>Callers should consider caching the returned metadata. Use {@link #getResourceSubscriptionMD5(int)} to get the
  160. * MD5 hashcode of the metadata for the resource to aid in determining when a cache of metadata is stale.</p>
  161. *
  162. * @param resourceId identifies the resource requesting the data; all package versions in all the resource's
  163. * subscribed repos will be represented in the returned map
  164. * @param pc this method can potentially return a large set; this page control object allows the caller to
  165. * page through that large set, as opposed to requesting the entire set in one large chunk
  166. *
  167. * @return the list of all package versions' metadata
  168. */
  169. @LimitedConcurrency(CONCURRENCY_LIMIT_CONTENT_DOWNLOAD)
  170. PageList<PackageVersionMetadataComposite> getPackageVersionMetadata(int resourceId, PageControl pc);
  171. /**
  172. * Gets the MD5 hash of the resource's "content subscription". If any changes were made to the repos this
  173. * resource is subscribed to, a changed MD5 will be returned.
  174. *
  175. * @param resourceId identifies the resource requesting the MD5; if any change to any package version in any
  176. * resource's subscribed repos will be used when generating the MD5
  177. *
  178. * @return the MD5 of all package versions' metadata
  179. *
  180. * @see #getPackageVersionMetadata(int, PageControl)
  181. */
  182. String getResourceSubscriptionMD5(int resourceId);
  183. /**
  184. * Requests the size, in bytes, of the identified package version.
  185. *
  186. * @param resourceId identifies the resource requesting the info
  187. * @param packageDetailsKey identifies the package whose size is to be returned
  188. *
  189. * @return the size, in number of bytes, of the package version
  190. */
  191. long getPackageBitsLength(int resourceId, PackageDetailsKey packageDetailsKey);
  192. /**
  193. * Requests loading of lazy loaded package. By this method the package content will be
  194. * loaded to server and ready to stream to the client.
  195. *
  196. * @param resourceId
  197. * @param packageDetailsKey
  198. * @return
  199. */
  200. @Timeout(90 * 60 * 1000L)
  201. @LimitedConcurrency(CONCURRENCY_LIMIT_CONTENT_DOWNLOAD)
  202. boolean preLoadRemoteContent(int resourceId, PackageDetailsKey packageDetailsKey);
  203. }