8d7fb3865a91fd892e972420da89bd574b4e178b
configuration/environments_scripts/sailing_server/files/usr/local/bin/refreshInstance.sh
| ... | ... | @@ -153,11 +153,11 @@ install_environment () |
| 153 | 153 | load_from_release_file () |
| 154 | 154 | { |
| 155 | 155 | if [[ ${INSTALL_FROM_RELEASE} == "" ]]; then |
| 156 | - GITHUB_RELEASE=$( curl -L "https://api.github.com/repos/SAP/sailing-analytics/releases?per_page=100" 2>/dev/null | jq -r 'sort_by(.created_at) | reverse | map(select(.name | startswith("main-")))[0].assets[] | select(.content_type=="application/x-tar")' ) |
|
| 156 | + GITHUB_RELEASE=$( curl -L "https://api.github.com/repos/SAP/sailing-analytics/releases?per_page=100" 2>/dev/null | jq -r 'map(select(.name | startswith("main-")) | .assets[] | select(.content_type=="application/x-tar")) | sort_by(.created_at) | reverse | first' ) |
|
| 157 | 157 | INSTALL_FROM_RELEASE=$( echo "${GITHUB_RELEASE}" | jq -r '.name' | sed -e 's/\.tar\.gz$//' ) |
| 158 | 158 | echo "You didn't provide a release. Defaulting to latest main branch build ${INSTALL_FROM_RELEASE}" |
| 159 | 159 | else |
| 160 | - GITHUB_RELEASE=$( curl -L "https://api.github.com/repos/SAP/sailing-analytics/releases?per_page=100" 2>/dev/null | jq -r 'sort_by(.created_at) | reverse | map(select(.name=="'${INSTALL_FROM_RELEASE}'"))[0].assets[] | select(.content_type=="application/x-tar")' ) |
|
| 160 | + GITHUB_RELEASE=$( curl -L "https://api.github.com/repos/SAP/sailing-analytics/releases?per_page=100" 2>/dev/null | jq -r 'map(select(.name=="'${INSTALL_FROM_RELEASE}'") | .assets[] | select(.content_type=="application/x-tar")) | sort_by(.created_at) | reverse | first' ) |
|
| 161 | 161 | fi |
| 162 | 162 | if which mail; then |
| 163 | 163 | if [ -n "${BUILD_COMPLETE_NOTIFY}" ]; then |
java/com.sap.sailing.server/SailingServer (No Proxy).launch
| ... | ... | @@ -14,6 +14,9 @@ |
| 14 | 14 | <setAttribute key="deselected_workspace_bundles"/> |
| 15 | 15 | <booleanAttribute key="includeOptional" value="false"/> |
| 16 | 16 | <booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/> |
| 17 | + <mapAttribute key="org.eclipse.debug.core.environmentVariables"> |
|
| 18 | + <mapEntry key="GITHUB_TOKEN" value="${GITHUB_TOKEN}"/> |
|
| 19 | + </mapAttribute> |
|
| 17 | 20 | <stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"/> |
| 18 | 21 | <stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;directory nest=&quot;false&quot; path=&quot;C:\Users\georg\Documents\Business\Kunden\OIO\SAPsailing\jetty.project\apache-jsp\src\main\java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.directory"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;classpathContainer path=&quot;com.google.gwt.eclipse.core.GWT_CONTAINER&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.classpathContainer"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/> |
| 19 | 22 | <listAttribute key="org.eclipse.debug.ui.favoriteGroups"> |
java/com.sap.sse.landscape/src/com/sap/sse/landscape/impl/GithubReleasesRepository.java
| ... | ... | @@ -3,6 +3,7 @@ package com.sap.sse.landscape.impl; |
| 3 | 3 | import java.io.IOException; |
| 4 | 4 | import java.io.InputStream; |
| 5 | 5 | import java.io.InputStreamReader; |
| 6 | +import java.net.HttpURLConnection; |
|
| 6 | 7 | import java.net.MalformedURLException; |
| 7 | 8 | import java.net.URL; |
| 8 | 9 | import java.net.URLConnection; |
| ... | ... | @@ -24,6 +25,7 @@ import org.json.simple.parser.ParseException; |
| 24 | 25 | |
| 25 | 26 | import com.sap.sse.common.Duration; |
| 26 | 27 | import com.sap.sse.common.TimePoint; |
| 28 | +import com.sap.sse.common.Util; |
|
| 27 | 29 | import com.sap.sse.common.Util.Pair; |
| 28 | 30 | import com.sap.sse.landscape.Release; |
| 29 | 31 | import com.sap.sse.landscape.ReleaseRepository; |
| ... | ... | @@ -153,8 +155,8 @@ public class GithubReleasesRepository extends AbstractReleaseRepository implemen |
| 153 | 155 | } else { |
| 154 | 156 | logger.fine(()->"Need to fetch page with newest releases because last request was at "+ |
| 155 | 157 | (lastFetchOfNewestReleases==null?"<never>":lastFetchOfNewestReleases)); |
| 156 | - lastFetchOfNewestReleases = now; |
|
| 157 | 158 | fillCacheWithNewestReleases(); |
| 159 | + lastFetchOfNewestReleases = now; |
|
| 158 | 160 | } |
| 159 | 161 | cachedReleasesIterator = releasesByPublishingTimePoint.descendingMap().values().iterator(); |
| 160 | 162 | } |
| ... | ... | @@ -215,6 +217,11 @@ public class GithubReleasesRepository extends AbstractReleaseRepository implemen |
| 215 | 217 | * cache when this method is invoked. |
| 216 | 218 | * <p> |
| 217 | 219 | * |
| 220 | + * If the {@code GITHUB_TOKEN} environment variable is set, it is used as a bearer token forthe Github requests, |
|
| 221 | + * resulting in a higher rate limit. If no token is set, or if using the token results in a 401 response code |
|
| 222 | + * (authentication failed), an unauthenticated request is tried instead. |
|
| 223 | + * <p> |
|
| 224 | + * |
|
| 218 | 225 | * The method makes no changes to the cache or any other state of this instance. |
| 219 | 226 | * |
| 220 | 227 | * @return the link to the next page in the returned pair's {@link Pair#getA() A component}, and the sequence of |
| ... | ... | @@ -222,7 +229,24 @@ public class GithubReleasesRepository extends AbstractReleaseRepository implemen |
| 222 | 229 | */ |
| 223 | 230 | private synchronized Pair<String, Iterable<Pair<TimePoint, GithubRelease>>> getReleasesFromPage(String pageURL) throws IOException, ParseException { |
| 224 | 231 | logger.info("Requesting releases page "+pageURL); |
| 225 | - final URLConnection connection = HttpUrlConnectionHelper.redirectConnection(new URL(pageURL)); |
|
| 232 | + final URLConnection connection; |
|
| 233 | + final String githubToken = System.getenv("GITHUB_TOKEN"); |
|
| 234 | + if (Util.hasLength(githubToken)) { |
|
| 235 | + final HttpURLConnection authenticatedConnectionAttempt = (HttpURLConnection) HttpUrlConnectionHelper |
|
| 236 | + .redirectConnectionWithBearerToken(new URL(pageURL), githubToken); |
|
| 237 | + if (authenticatedConnectionAttempt.getResponseCode() == 401) { |
|
| 238 | + try { |
|
| 239 | + authenticatedConnectionAttempt.disconnect(); |
|
| 240 | + } catch (Exception e) { |
|
| 241 | + logger.warning("Couldn't disconnect from Github: "+e.getMessage()); |
|
| 242 | + } |
|
| 243 | + connection = HttpUrlConnectionHelper.redirectConnection(new URL(pageURL)); |
|
| 244 | + } else { |
|
| 245 | + connection = authenticatedConnectionAttempt; |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | + connection = HttpUrlConnectionHelper.redirectConnection(new URL(pageURL)); |
|
| 249 | + } |
|
| 226 | 250 | final InputStream index = (InputStream) connection.getContent(); |
| 227 | 251 | final String xRatelimitRemaining = connection.getHeaderField("x-ratelimit-remaining"); |
| 228 | 252 | logger.fine(()->""+xRatelimitRemaining+" requests left in this hour"); |
java/target/compareServers
| ... | ... | @@ -68,15 +68,15 @@ if [ "${useRestApi}" = "1" ]; then |
| 68 | 68 | shift |
| 69 | 69 | done |
| 70 | 70 | CURL_OUTPUT=$( curl -sL --dump-header "${HEADERS}" -H 'Content-Type: multipart/form-data' "${NEWSERVER}/sailingserver/api/v1/compareservers" -d "server2=${OLDSERVER}" ${AUTH} ${LEADERBOARD_GROUPS} 2>${WGET_ERR} ) |
| 71 | - echo "${CURL_OUTPUT}" | jq |
|
| 71 | + echo "${CURL_OUTPUT}" |
|
| 72 | 72 | HTTP_STATUS=$( cat "${HEADERS}" | grep "^HTTP\/[0-9.]* [0-9]\{3\}" | tail -1 | sed -e 's/^HTTP\/[0-9.]* \([0-9]\{3\}\).*$/\1/' ) |
| 73 | 73 | rm -f "${HEADERS}" |
| 74 | 74 | MESSAGE_SUFFIX=". HTTP_STATUS was ${HTTP_STATUS}." |
| 75 | 75 | if [[ "${HTTP_STATUS}" =~ 2.. ]]; then |
| 76 | - echo "Success${MESSAGE_SUFFIX}" |
|
| 76 | + echo "Success${MESSAGE_SUFFIX}" >&2 |
|
| 77 | 77 | exit 0 |
| 78 | 78 | else |
| 79 | - echo "Failed${MESSAGE_SUFFIX}" |
|
| 79 | + echo "Failed${MESSAGE_SUFFIX}" >&2 |
|
| 80 | 80 | exit ${HTTP_STATUS} |
| 81 | 81 | fi |
| 82 | 82 | else |
java/target/env-default-rules.sh
| ... | ... | @@ -140,3 +140,4 @@ fi |
| 140 | 140 | if [ -n "${GEONAMES_ORG_USERNAMES}" ]; then |
| 141 | 141 | ADDITIONAL_JAVA_ARGS="${ADDITIONAL_JAVA_ARGS} -Dgeonames.org.usernames=${GEONAMES_ORG_USERNAMES}" |
| 142 | 142 | fi |
| 143 | +export GITHUB_TOKEN |
wiki/howto/onboarding.md
| ... | ... | @@ -115,6 +115,7 @@ Go to Window ⇒ Preferences and change the following two settings: |
| 115 | 115 | - For YouTube API access, provide an Eclipse variable ``YOUTUBE_API_KEY``. You can use your own Google developer account to create such a key; see [here](https://console.cloud.google.com). |
| 116 | 116 | - In case you need to test with the payment provider (ChargeBee) active, you need to provide Eclipse variables (Run/Rebug ⇒ String Substitution) ``CHARGEBEE_SITE`` and ``CHARGEBEE_API_KEY`` where the recommendation is to use ``sailytics-test`` for the site and a corresponding test API key; there is one launch configuration running against the live ChargeBee site, but its use is not recommended for obvious reasons. For it, define the variables ``CHARGEBEE_SITE_LIVE`` and ``CHARGEBEE_API_KEY_LIVE``, respectively. |
| 117 | 117 | - To successfully obtain polar and wind estimation data from ``sapsailing.com``, you need to define the Eclipse variables (Run/Debug ⇒ String Substitution) ``POLAR_DATA_BEARER_TOKEN`` and ``WIND_ESTIMATION_MODEL_BEARER_TOKEN`` that need to authenticate a user with permissions to read the respective models. |
| 118 | +- Define a ``GITHUB_TOKEN`` variable; it may be empty (but has to be generally present), or you can use it to set a personal access token (PAT) which will then be used, in particular, for requesting application releases from GitHub. |
|
| 118 | 119 | - To work with the wind estimation model training launch configuration (e.g., SimpleModelsTrainingPart1.launch), define an Eclipse variable (Run/Debug ⇒ String Substitution) ``SAPSAILING_BEARER_TOKEN`` which needs to authenticate a user eligible to read all maneuver data from sapsailing.com |
| 119 | 120 | - In "GWT ⇒ Errors/Warnings" set "Missing SDK" to "Ignore" |
| 120 | 121 | - In "GWT ⇒ GWT Settings ⇒ Add..." add the GWT SDK you downloaded and unpacked earlier |