author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
426,496
17.06.2020 13:31:45
-7,200
bf0c54d5f28db5af6a3a8b4557fd35870c3a91f6
Instructions to run database/model-server/ui-server without kubernetes
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -9,18 +9,18 @@ Cloud storage and web UI for MPS\n- https://console.cloud.google.com/kubernetes/list?project=webmps\n- Create cluster\n- - Name: cloudmps\n+ - Name: modelix\n- Zone: europe-west-3c\n- Pool\n- Number of nodes: 1\n- Machine type: n1-standard-2\n-- `gcloud container clusters get-credentials cloudmps`\n+- `gcloud container clusters get-credentials modelix`\n- `./gradlew`\n- `./docker-build-all.sh`\n- `./docker-push-hub.sh`\n- `kubectl create secret generic cloudsql-instance-credentials --from-file=./kubernetes/secrets/cloudsql.json`\n-- `kubectl create secret generic modelsecret --from-file=./kubernetes/secrets/modelsecret.txt`\n-- SSL certificate\n+- `./kubernetes-modelsecret.sh`\n+- SSL certificate (not supported yet)\n- `cd ssl`\n- `./generate.sh`\n- `./kubernetes-create-secret.sh`\n@@ -38,9 +38,21 @@ Cloud storage and web UI for MPS\n- minikube start --cpus=6 --memory=12GB --disk-size=40GB\n-- `kubectl create secret generic modelsecret --from-file=./kubernetes/secrets/modelsecret.txt`\n-- SSL certificate\n+- `./kubernetes-modelsecret.sh`\n+- SSL certificate (not supported yet)\n- `cd ssl`\n- `./generate.sh`\n- `./kubernetes-create-secret.sh`\n- `./kubernetes-apply-local.sh`\n+\n+## Run without kubernetes\n+\n+- database\n+ - Change the port in `model-server/src/main/resources/org/modelix/model/server/database.properties` to 54333 or change the port in `./docker-run-db.sh` to 5432\n+ - `./docker-run-db.sh`\n+- model server\n+ - `cd model-server`\n+ - `./gradlew run\n+- UI server\n+ - open the project in the folder \"mps\" with MPS\n+ - <http://localhost:33333/>\n" }, { "change_type": "ADD", "old_path": null, "new_path": "generate-modelsecret.sh", "diff": "+#!/bin/sh\n+\n+mkdir -p ./kubernetes/secrets/\n+\n+cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | head -c 32 > ./kubernetes/secrets/modelsecret.txt\n+\n" }, { "change_type": "MODIFY", "old_path": "kubernetes-modelsecret.sh", "new_path": "kubernetes-modelsecret.sh", "diff": "#!/bin/sh\n+if [ ! -f ./kubernetes/secrets/modelsecret.txt ]; then\n+ ./generate-modelsecret.sh\n+fi\n+\nkubectl create secret generic modelsecret --from-file=./kubernetes/secrets/modelsecret.txt\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "-\n+plugins {\n+ id \"application\"\n+}\napply plugin: 'java'\ngroup = 'org.modelix'\n@@ -43,3 +45,7 @@ task copyLibs(type: Copy) {\n}\nassemble.finalizedBy(copyLibs)\n+\n+application {\n+ mainClassName = \"org.modelix.model.server.Main\"\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-server/gradle/wrapper/gradle-wrapper.properties", "new_path": "model-server/gradle/wrapper/gradle-wrapper.properties", "diff": "+#Wed Jun 17 13:05:44 CEST 2020\n+distributionUrl=https\\://services.gradle.org/distributions/gradle-5.2.1-all.zip\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\n-distributionUrl=https\\://services.gradle.org/distributions/gradle-5.2.1-bin.zip\n-zipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n+zipStoreBase=GRADLE_USER_HOME\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Instructions to run database/model-server/ui-server without kubernetes
426,496
17.06.2020 13:32:23
-7,200
729bda103243f4df447d1a14e9d0e31b689e0907
Changed default model server URL from cloudmps.q60.de to modelix.q60.de
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.mps", "new_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.mps", "diff": "<node concept=\"3clFbS\" id=\"65d3h4jaOSe\" role=\"9aQI4\">\n<node concept=\"3cpWs6\" id=\"1LVcV5KyY8w\" role=\"3cqZAp\">\n<node concept=\"Xl_RD\" id=\"6lVG1TvblSi\" role=\"3cqZAk\">\n- <property role=\"Xl_RC\" value=\"http://cloudmps.q60.de:80/model/\" />\n+ <property role=\"Xl_RC\" value=\"http://modelix.q60.de:80/model/\" />\n</node>\n</node>\n</node>\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Changed default model server URL from cloudmps.q60.de to modelix.q60.de
426,496
17.06.2020 13:58:26
-7,200
db8c11b2ec2cd4270d7b458f9454752cdb367366
Renaming in string literals for actions groups Fixes
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.history.mps", "new_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.history.mps", "diff": "<ref role=\"37wK5l\" to=\"7bx7:~ActionUtils.getGroup(java.lang.String)\" resolve=\"getGroup\" />\n<ref role=\"1Pybhc\" to=\"7bx7:~ActionUtils\" resolve=\"ActionUtils\" />\n<node concept=\"Xl_RD\" id=\"6aRQr1WOkvN\" role=\"37wK5m\">\n- <property role=\"Xl_RC\" value=\"de.q60.mps.web.model.mpsplugin.plugin.CloudRootGroup_ActionGroup\" />\n+ <property role=\"Xl_RC\" value=\"org.modelix.model.mpsplugin.plugin.CloudRootGroup_ActionGroup\" />\n</node>\n</node>\n</node>\n<ref role=\"37wK5l\" to=\"7bx7:~ActionUtils.getGroup(java.lang.String)\" resolve=\"getGroup\" />\n<ref role=\"1Pybhc\" to=\"7bx7:~ActionUtils\" resolve=\"ActionUtils\" />\n<node concept=\"Xl_RD\" id=\"6aRQr1XcUXW\" role=\"37wK5m\">\n- <property role=\"Xl_RC\" value=\"de.q60.mps.web.model.mpsplugin.plugin.CloudRepositoryGroup_ActionGroup\" />\n+ <property role=\"Xl_RC\" value=\"org.modelix.model.mpsplugin.plugin.CloudRepositoryGroup_ActionGroup\" />\n</node>\n</node>\n</node>\n<ref role=\"37wK5l\" to=\"7bx7:~ActionUtils.getGroup(java.lang.String)\" resolve=\"getGroup\" />\n<ref role=\"1Pybhc\" to=\"7bx7:~ActionUtils\" resolve=\"ActionUtils\" />\n<node concept=\"Xl_RD\" id=\"49CIzaqr07$\" role=\"37wK5m\">\n- <property role=\"Xl_RC\" value=\"de.q60.mps.web.model.mpsplugin.plugin.CloudNodeGroup_ActionGroup\" />\n+ <property role=\"Xl_RC\" value=\"org.modelix.model.mpsplugin.plugin.CloudNodeGroup_ActionGroup\" />\n</node>\n</node>\n</node>\n<ref role=\"37wK5l\" to=\"7bx7:~ActionUtils.getGroup(java.lang.String)\" resolve=\"getGroup\" />\n<ref role=\"1Pybhc\" to=\"7bx7:~ActionUtils\" resolve=\"ActionUtils\" />\n<node concept=\"Xl_RD\" id=\"2n9WvfbmayX\" role=\"37wK5m\">\n- <property role=\"Xl_RC\" value=\"de.q60.mps.web.model.mpsplugin.plugin.CloudTreeGroup_ActionGroup\" />\n+ <property role=\"Xl_RC\" value=\"org.modelix.model.mpsplugin.plugin.CloudTreeGroup_ActionGroup\" />\n</node>\n</node>\n</node>\n<ref role=\"37wK5l\" to=\"7bx7:~ActionUtils.getGroup(java.lang.String)\" resolve=\"getGroup\" />\n<ref role=\"1Pybhc\" to=\"7bx7:~ActionUtils\" resolve=\"ActionUtils\" />\n<node concept=\"Xl_RD\" id=\"2n9WvfbmUyv\" role=\"37wK5m\">\n- <property role=\"Xl_RC\" value=\"de.q60.mps.web.model.mpsplugin.plugin.CloudBranchGroup_ActionGroup\" />\n+ <property role=\"Xl_RC\" value=\"org.modelix.model.mpsplugin.plugin.CloudBranchGroup_ActionGroup\" />\n</node>\n</node>\n</node>\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.sm.server/models/org.modelix.ui.sm.server.plugin.mps", "new_path": "mps/org.modelix.ui.sm.server/models/org.modelix.ui.sm.server.plugin.mps", "diff": "<node concept=\"3clFbS\" id=\"7q7cTU0Y2Cg\" role=\"2VODD2\">\n<node concept=\"RRSsy\" id=\"2wu1c06OJqL\" role=\"3cqZAp\">\n<node concept=\"Xl_RD\" id=\"2wu1c06OJD$\" role=\"RRSoy\">\n- <property role=\"Xl_RC\" value=\"de.q60.mps.web.ui.sm.server plugin loaded\" />\n+ <property role=\"Xl_RC\" value=\"org.modelix.ui.sm.server plugin loaded\" />\n</node>\n</node>\n<node concept=\"RRSsy\" id=\"2wu1c06OJZ6\" role=\"3cqZAp\">\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Renaming in string literals for actions groups Fixes https://github.com/modelix/modelix/issues/1
426,496
18.06.2020 11:01:41
-7,200
2e2543dea828900060d3a68b3aedb8e42c2e1ca6
More instructions in the README
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "-# WebMPS\n+# modelix\n<a href=\"https://build.mbeddr.com/project.html?projectId=WebMps_WebMpsBuild&tab=projectOverview\"><img src=\"http://build.mbeddr.com/app/rest/builds/buildType:(id:WebMps_WebMpsBuild)/statusIcon\"/></a>\n-\nCloud storage and web UI for MPS\n-## Build and run in the google cloud\n+# How to run modelix\n+\n+In production modelix uses docker images running in a kubernetes cluster.\n+During development you can run the different components without docker/kubernetes.\n+You need a PostgreSQL database, the model server and the MPS plugin for the UI server.\n+\n+## Running without kubernetes\n+\n+While you can install PostgreSQL locally it's easier to just run the docker image.\n+This gives you an empty ready to use database each time you restart the docker image.\n+If you still want to install a PostgreSQL server check the files [./db/initdb.sql] and\n+[./model-server/src/main/resources/org/modelix/model/server/database.properties].\n+\n+- database\n+ - Change the port in [./model-server/src/main/resources/org/modelix/model/server/database.properties] to 54333 or change the port in [./docker-run-db.sh] to 5432\n+ - `./docker-build-db.sh`\n+ - `./docker-run-db.sh`\n+- model server\n+ - `cd model-server`\n+ - `./gradlew run\n+- UI server\n+ - open the project in the folder \"mps\" with MPS\n+ - <http://localhost:33333/>\n+\n+## Running with minikube\n+\n+- minikube start --cpus=6 --memory=12GB --disk-size=40GB\n+\n+- `./kubernetes-modelsecret.sh`\n+- SSL certificate (not supported yet)\n+ - `cd ssl`\n+ - `./generate.sh`\n+ - `./kubernetes-create-secret.sh`\n+- `./kubernetes-apply-local.sh`\n+\n+## Running in the google cloud\n- https://console.cloud.google.com/kubernetes/list?project=webmps\n- Create cluster\n@@ -34,25 +68,3 @@ Cloud storage and web UI for MPS\n- `./docker-push.sh`\n- `kubectl apply -f deployment.yaml -f service.yaml`\n-## Build and run local with minikube\n-\n-- minikube start --cpus=6 --memory=12GB --disk-size=40GB\n-\n-- `./kubernetes-modelsecret.sh`\n-- SSL certificate (not supported yet)\n- - `cd ssl`\n- - `./generate.sh`\n- - `./kubernetes-create-secret.sh`\n-- `./kubernetes-apply-local.sh`\n-\n-## Run without kubernetes\n-\n-- database\n- - Change the port in `model-server/src/main/resources/org/modelix/model/server/database.properties` to 54333 or change the port in `./docker-run-db.sh` to 5432\n- - `./docker-run-db.sh`\n-- model server\n- - `cd model-server`\n- - `./gradlew run\n-- UI server\n- - open the project in the folder \"mps\" with MPS\n- - <http://localhost:33333/>\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
More instructions in the README
426,496
18.06.2020 12:53:24
-7,200
79f9b0ed4b166b2156149630c8949c3a5513c075
Parameters for the downloadModel gradle task
[ { "change_type": "ADD", "old_path": null, "new_path": "gradle-plugin-test/.idea/compiler.xml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<project version=\"4\">\n+ <component name=\"CompilerConfiguration\">\n+ <bytecodeTargetLevel target=\"1.8\" />\n+ </component>\n+</project>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "gradle-plugin-test/.idea/jarRepositories.xml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<project version=\"4\">\n+ <component name=\"RemoteRepositoriesConfiguration\">\n+ <remote-repository>\n+ <option name=\"id\" value=\"central\" />\n+ <option name=\"name\" value=\"Maven Central repository\" />\n+ <option name=\"url\" value=\"https://repo1.maven.org/maven2\" />\n+ </remote-repository>\n+ <remote-repository>\n+ <option name=\"id\" value=\"jboss.community\" />\n+ <option name=\"name\" value=\"JBoss Community repository\" />\n+ <option name=\"url\" value=\"https://repository.jboss.org/nexus/content/repositories/public/\" />\n+ </remote-repository>\n+ <remote-repository>\n+ <option name=\"id\" value=\"MavenRepo\" />\n+ <option name=\"name\" value=\"MavenRepo\" />\n+ <option name=\"url\" value=\"https://repo.maven.apache.org/maven2/\" />\n+ </remote-repository>\n+ <remote-repository>\n+ <option name=\"id\" value=\"MavenLocal\" />\n+ <option name=\"name\" value=\"MavenLocal\" />\n+ <option name=\"url\" value=\"file:$MAVEN_REPOSITORY$/\" />\n+ </remote-repository>\n+ </component>\n+</project>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "gradle-plugin-test/.idea/misc.xml", "new_path": "gradle-plugin-test/.idea/misc.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n<component name=\"ExternalStorageConfigurationManager\" enabled=\"true\" />\n- <component name=\"ProjectRootManager\" version=\"2\" languageLevel=\"JDK_1_8\" project-jdk-name=\"1.8\" project-jdk-type=\"JavaSDK\">\n+ <component name=\"FrameworkDetectionExcludesConfiguration\">\n+ <file type=\"web\" url=\"file://$PROJECT_DIR$\" />\n+ </component>\n+ <component name=\"ProjectRootManager\" version=\"2\" languageLevel=\"JDK_1_8\" default=\"true\" project-jdk-name=\"1.8\" project-jdk-type=\"JavaSDK\">\n<output url=\"file://$PROJECT_DIR$/out\" />\n</component>\n</project>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "gradle-plugin-test/build.gradle", "new_path": "gradle-plugin-test/build.gradle", "diff": "@@ -27,3 +27,8 @@ dependencies {\n}\napply plugin: 'modelix-gradle-plugin'\n+\n+downloadModel {\n+ serverUrl = \"http://localhost:28101/\"\n+ treeId = \"defaultTree\"\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "gradle-plugin/src/main/java/org/modelix/gradle/model/DownloadModelTask.java", "new_path": "gradle-plugin/src/main/java/org/modelix/gradle/model/DownloadModelTask.java", "diff": "@@ -5,10 +5,29 @@ import org.gradle.api.tasks.TaskAction;\npublic class DownloadModelTask extends DefaultTask {\n+ private String serverUrl;\n+ private String treeId;\n+\n+ public String getServerUrl() {\n+ return serverUrl;\n+ }\n+\n+ public void setServerUrl(String serverUrl) {\n+ this.serverUrl = serverUrl;\n+ }\n+\n+ public String getTreeId() {\n+ return treeId;\n+ }\n+\n+ public void setTreeId(String treeId) {\n+ this.treeId = treeId;\n+ }\n+\n@TaskAction\npublic void downloadModel() {\nSystem.out.println(\"modelix gradle plugin\");\n- System.out.println(\"Downloading model ...\");\n+ System.out.println(\"Downloading tree \" + getTreeId() + \" from \" + getServerUrl() + \" ...\");\nSystem.out.println(\"Done.\");\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Parameters for the downloadModel gradle task
426,496
18.06.2020 12:53:54
-7,200
6eacd24ce8cfa3fe67b7652791794cd43954d89b
Migrated the entities MPS project to MPS 2020.1
[ { "change_type": "MODIFY", "old_path": "samples/entities/.mps/vcs.xml", "new_path": "samples/entities/.mps/vcs.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n<component name=\"VcsDirectoryMappings\">\n- <mapping directory=\"$webmps.home$\" vcs=\"Git\" />\n<mapping directory=\"$PROJECT_DIR$/../..\" vcs=\"Git\" />\n</component>\n</project>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "samples/entities/languages/org.modelix.samples.entities/models/org.modelix.samples.entities.editor.mps", "new_path": "samples/entities/languages/org.modelix.samples.entities/models/org.modelix.samples.entities.editor.mps", "diff": "<model ref=\"r:38d3cf5c-d4d8-42df-8b8a-97895c92f72f(org.modelix.samples.entities.editor)\">\n<persistence version=\"9\" />\n<languages>\n- <use id=\"18bc6592-03a6-4e29-a83a-7ff23bde13ba\" name=\"jetbrains.mps.lang.editor\" version=\"13\" />\n+ <use id=\"18bc6592-03a6-4e29-a83a-7ff23bde13ba\" name=\"jetbrains.mps.lang.editor\" version=\"14\" />\n<devkit ref=\"fbc25dd2-5da4-483a-8b19-70928e1b62d7(jetbrains.mps.devkit.general-purpose)\" />\n</languages>\n<imports>\n" }, { "change_type": "MODIFY", "old_path": "samples/entities/languages/org.modelix.samples.entities/org.modelix.samples.entities.mpl", "new_path": "samples/entities/languages/org.modelix.samples.entities/org.modelix.samples.entities.mpl", "diff": "</facets>\n<external-templates />\n<languageVersions>\n- <language slang=\"l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage\" version=\"9\" />\n+ <language slang=\"l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage\" version=\"11\" />\n<language slang=\"l:fd392034-7849-419d-9071-12563d152375:jetbrains.mps.baseLanguage.closures\" version=\"0\" />\n<language slang=\"l:83888646-71ce-4f1c-9c53-c54016f6ad4f:jetbrains.mps.baseLanguage.collections\" version=\"1\" />\n<language slang=\"l:f2801650-65d5-424e-bb1b-463a8781b786:jetbrains.mps.baseLanguage.javadoc\" version=\"2\" />\n<language slang=\"l:d7706f63-9be2-479c-a3da-ae92af1e64d5:jetbrains.mps.lang.generator.generationContext\" version=\"2\" />\n<language slang=\"l:289fcc83-6543-41e8-a5ca-768235715ce4:jetbrains.mps.lang.generator.generationParameters\" version=\"0\" />\n<language slang=\"l:446c26eb-2b7b-4bf0-9b35-f83fa582753e:jetbrains.mps.lang.modelapi\" version=\"0\" />\n- <language slang=\"l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation\" version=\"4\" />\n+ <language slang=\"l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation\" version=\"5\" />\n<language slang=\"l:13744753-c81f-424a-9c1b-cf8943bf4e86:jetbrains.mps.lang.sharedConcepts\" version=\"0\" />\n<language slang=\"l:7866978e-a0f0-4cc7-81bc-4d213d9375e1:jetbrains.mps.lang.smodel\" version=\"17\" />\n<language slang=\"l:c7fb639f-be78-4307-89b0-b5959c3fa8c8:jetbrains.mps.lang.text\" version=\"0\" />\n<language slang=\"l:6f76dbc8-9615-4a2e-8034-c27700f8983b:de.q60.mps.shadowmodels.gen.desugar\" version=\"0\" />\n<language slang=\"l:c6082896-edff-4380-997b-5b96de2fdc12:de.q60.mps.shadowmodels.gen.typesystem\" version=\"0\" />\n<language slang=\"l:94b64715-a263-4c36-a138-8da14705ffa7:de.q60.mps.shadowmodels.transformation\" version=\"1\" />\n- <language slang=\"l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage\" version=\"9\" />\n+ <language slang=\"l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage\" version=\"11\" />\n<language slang=\"l:774bf8a0-62e5-41e1-af63-f4812e60e48b:jetbrains.mps.baseLanguage.checkedDots\" version=\"0\" />\n<language slang=\"l:443f4c36-fcf5-4eb6-9500-8d06ed259e3e:jetbrains.mps.baseLanguage.classifiers\" version=\"0\" />\n<language slang=\"l:fd392034-7849-419d-9071-12563d152375:jetbrains.mps.baseLanguage.closures\" version=\"0\" />\n<language slang=\"l:ea3159bf-f48e-4720-bde2-86dba75f0d34:jetbrains.mps.lang.context.defs\" version=\"0\" />\n<language slang=\"l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core\" version=\"2\" />\n<language slang=\"l:f4ad079d-bc71-4ffb-9600-9328705cf998:jetbrains.mps.lang.descriptor\" version=\"0\" />\n- <language slang=\"l:18bc6592-03a6-4e29-a83a-7ff23bde13ba:jetbrains.mps.lang.editor\" version=\"13\" />\n+ <language slang=\"l:18bc6592-03a6-4e29-a83a-7ff23bde13ba:jetbrains.mps.lang.editor\" version=\"14\" />\n<language slang=\"l:ad93155d-79b2-4759-b10c-55123e763903:jetbrains.mps.lang.messages\" version=\"0\" />\n<language slang=\"l:446c26eb-2b7b-4bf0-9b35-f83fa582753e:jetbrains.mps.lang.modelapi\" version=\"0\" />\n<language slang=\"l:d4615e3b-d671-4ba9-af01-2b78369b0ba7:jetbrains.mps.lang.pattern\" version=\"2\" />\n- <language slang=\"l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation\" version=\"4\" />\n+ <language slang=\"l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation\" version=\"5\" />\n<language slang=\"l:982eb8df-2c96-4bd7-9963-11712ea622e5:jetbrains.mps.lang.resources\" version=\"2\" />\n<language slang=\"l:b3551702-269c-4f05-ba61-58060cef4292:jetbrains.mps.lang.rulesAndMessages\" version=\"0\" />\n<language slang=\"l:d8f591ec-4d86-4af2-9f92-a9e93c803ffa:jetbrains.mps.lang.scopes\" version=\"0\" />\n<module reference=\"87f4b21e-a3a5-459e-a54b-408fd9eb7350(org.modelix.lib)\" version=\"0\" />\n<module reference=\"363848cf-91df-484c-9066-7089821cb609(org.modelix.samples.entities)\" version=\"0\" />\n<module reference=\"da981293-1ec2-4df0-95e4-df162984154c(org.modelix.ui.common)\" version=\"0\" />\n- <module reference=\"78874af2-5dd2-42a7-a21d-42fab3737d1d(org.modelix.ui.sm)\" version=\"0\" />\n+ <module reference=\"78874af2-5dd2-42a7-a21d-42fab3737d1d(org.modelix.ui.sm)\" version=\"1\" />\n<module reference=\"6f6906a4-f244-4806-a98b-0bc781cef2a8(org.modelix.ui.sm.dom)\" version=\"0\" />\n<module reference=\"eb8d1040-bff5-4126-8949-fdd95ef4c502(org.modelix.ui.sm.server)\" version=\"0\" />\n</dependencyVersions>\n" }, { "change_type": "MODIFY", "old_path": "samples/entities/solutions/org.modelix.samples.entities.sandbox/models/org.modelix.samples.entities.sandbox.mps", "new_path": "samples/entities/solutions/org.modelix.samples.entities.sandbox/models/org.modelix.samples.entities.sandbox.mps", "diff": "<model ref=\"r:5d56df86-9b89-40e7-a17f-675bb0dc9ae2(org.modelix.samples.entities.sandbox)\">\n<persistence version=\"9\" />\n<languages>\n- <use id=\"363848cf-91df-484c-9066-7089821cb609\" name=\"de.q60.mps.web.samples.entities\" version=\"-1\" />\n+ <use id=\"363848cf-91df-484c-9066-7089821cb609\" name=\"org.modelix.samples.entities\" version=\"-1\" />\n<devkit ref=\"fbc25dd2-5da4-483a-8b19-70928e1b62d7(jetbrains.mps.devkit.general-purpose)\" />\n</languages>\n<imports />\n<concept id=\"1146644602865\" name=\"jetbrains.mps.baseLanguage.structure.PublicVisibility\" flags=\"nn\" index=\"3Tm1VV\" />\n<concept id=\"1146644623116\" name=\"jetbrains.mps.baseLanguage.structure.PrivateVisibility\" flags=\"nn\" index=\"3Tm6S6\" />\n</language>\n- <language id=\"363848cf-91df-484c-9066-7089821cb609\" name=\"de.q60.mps.web.samples.entities\">\n- <concept id=\"579439372628304764\" name=\"de.q60.mps.web.samples.entities.structure.EntityType\" flags=\"ng\" index=\"uq3pQ\">\n+ <language id=\"363848cf-91df-484c-9066-7089821cb609\" name=\"org.modelix.samples.entities\">\n+ <concept id=\"579439372628304764\" name=\"org.modelix.samples.entities.structure.EntityType\" flags=\"ng\" index=\"uq3pQ\">\n<reference id=\"579439372628304981\" name=\"entity\" index=\"uq35v\" />\n</concept>\n- <concept id=\"579439372628239967\" name=\"de.q60.mps.web.samples.entities.structure.StringType\" flags=\"ng\" index=\"uqNdl\" />\n- <concept id=\"7680480780028988222\" name=\"de.q60.mps.web.samples.entities.structure.Entity\" flags=\"ng\" index=\"3ZgkuH\">\n+ <concept id=\"579439372628239967\" name=\"org.modelix.samples.entities.structure.StringType\" flags=\"ng\" index=\"uqNdl\" />\n+ <concept id=\"7680480780028988222\" name=\"org.modelix.samples.entities.structure.Entity\" flags=\"ng\" index=\"3ZgkuH\">\n<child id=\"7680480780028993238\" name=\"properties\" index=\"3Zgl95\" />\n</concept>\n- <concept id=\"7680480780028993068\" name=\"de.q60.mps.web.samples.entities.structure.Property\" flags=\"ng\" index=\"3ZglaZ\">\n+ <concept id=\"7680480780028993068\" name=\"org.modelix.samples.entities.structure.Property\" flags=\"ng\" index=\"3ZglaZ\">\n<child id=\"579439372628240412\" name=\"type\" index=\"uqNOm\" />\n</concept>\n</language>\n" }, { "change_type": "MODIFY", "old_path": "samples/entities/solutions/org.modelix.samples.entities.sandbox/org.modelix.samples.entities.sandbox.msd", "new_path": "samples/entities/solutions/org.modelix.samples.entities.sandbox/org.modelix.samples.entities.sandbox.msd", "diff": "</facets>\n<sourcePath />\n<languageVersions>\n- <language slang=\"l:363848cf-91df-484c-9066-7089821cb609:de.q60.mps.web.samples.entities\" version=\"0\" />\n- <language slang=\"l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage\" version=\"9\" />\n+ <language slang=\"l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage\" version=\"11\" />\n<language slang=\"l:fd392034-7849-419d-9071-12563d152375:jetbrains.mps.baseLanguage.closures\" version=\"0\" />\n<language slang=\"l:83888646-71ce-4f1c-9c53-c54016f6ad4f:jetbrains.mps.baseLanguage.collections\" version=\"1\" />\n<language slang=\"l:f2801650-65d5-424e-bb1b-463a8781b786:jetbrains.mps.baseLanguage.javadoc\" version=\"2\" />\n<language slang=\"l:a247e09e-2435-45ba-b8d2-07e93feba96a:jetbrains.mps.baseLanguage.tuples\" version=\"0\" />\n<language slang=\"l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core\" version=\"2\" />\n<language slang=\"l:446c26eb-2b7b-4bf0-9b35-f83fa582753e:jetbrains.mps.lang.modelapi\" version=\"0\" />\n- <language slang=\"l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation\" version=\"4\" />\n+ <language slang=\"l:3a13115c-633c-4c5c-bbcc-75c4219e9555:jetbrains.mps.lang.quotation\" version=\"5\" />\n<language slang=\"l:7866978e-a0f0-4cc7-81bc-4d213d9375e1:jetbrains.mps.lang.smodel\" version=\"17\" />\n<language slang=\"l:c7fb639f-be78-4307-89b0-b5959c3fa8c8:jetbrains.mps.lang.text\" version=\"0\" />\n<language slang=\"l:9ded098b-ad6a-4657-bfd9-48636cfe8bc3:jetbrains.mps.lang.traceable\" version=\"0\" />\n+ <language slang=\"l:363848cf-91df-484c-9066-7089821cb609:org.modelix.samples.entities\" version=\"0\" />\n</languageVersions>\n<dependencyVersions>\n<module reference=\"37816bad-3884-4d62-aca8-51b1fe3a921e(org.modelix.samples.entities.sandbox)\" version=\"0\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Migrated the entities MPS project to MPS 2020.1
426,496
18.06.2020 13:26:01
-7,200
569e4b797f68522a4cfa4a5ae60cf4732a51d613
Added MPS-extensions as project library
[ { "change_type": "ADD", "old_path": null, "new_path": "mps/.mps/libraries.xml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<project version=\"4\">\n+ <component name=\"ProjectLibraryManager\">\n+ <option name=\"libraries\">\n+ <map>\n+ <entry key=\"MPS-extensions\">\n+ <value>\n+ <Library>\n+ <option name=\"name\" value=\"MPS-extensions\" />\n+ <option name=\"path\" value=\"$PROJECT_DIR$/../artifacts/de.itemis.mps.extensions\" />\n+ </Library>\n+ </value>\n+ </entry>\n+ </map>\n+ </option>\n+ </component>\n+</project>\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Added MPS-extensions as project library
426,496
18.06.2020 13:47:34
-7,200
4263151a8a1564722aab5421c01c9afc01dd0008
Removed unnecessary dependency from org.modelix.build.scripts
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.build.scripts/models/org.modelix.build.scripts.mps", "new_path": "mps/org.modelix.build.scripts/models/org.modelix.build.scripts.mps", "diff": "<imports>\n<import index=\"ffeo\" ref=\"r:874d959d-e3b4-4d04-b931-ca849af130dd(jetbrains.mps.ide.build)\" />\n<import index=\"90a9\" ref=\"r:fb24ac52-5985-4947-bba9-25be6fd32c1a(de.itemis.mps.extensions.build)\" />\n- <import index=\"n8nt\" ref=\"r:1a3990a4-de8c-42ac-906e-53de40277d4f(allScripts.build)\" />\n</imports>\n<registry>\n<language id=\"798100da-4f0a-421a-b991-71f8c50ce5d2\" name=\"jetbrains.mps.build\">\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.build.scripts/org.modelix.build.scripts.msd", "new_path": "mps/org.modelix.build.scripts/org.modelix.build.scripts.msd", "diff": "<dependencies>\n<dependency reexport=\"false\">422c2909-59d6-41a9-b318-40e6256b250f(jetbrains.mps.ide.build)</dependency>\n<dependency reexport=\"false\">f1fb7b1c-ce0d-423c-9369-4a661d600029(de.itemis.mps.extensions.build)</dependency>\n- <dependency reexport=\"false\">636fc566-0154-4fdf-9ecb-a4b788da967b(allScripts)</dependency>\n</dependencies>\n<languageVersions>\n<language slang=\"l:798100da-4f0a-421a-b991-71f8c50ce5d2:jetbrains.mps.build\" version=\"0\" />\n<language slang=\"l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core\" version=\"2\" />\n</languageVersions>\n<dependencyVersions>\n- <module reference=\"636fc566-0154-4fdf-9ecb-a4b788da967b(allScripts)\" version=\"0\" />\n<module reference=\"f1fb7b1c-ce0d-423c-9369-4a661d600029(de.itemis.mps.extensions.build)\" version=\"0\" />\n<module reference=\"422c2909-59d6-41a9-b318-40e6256b250f(jetbrains.mps.ide.build)\" version=\"0\" />\n<module reference=\"52634d8a-ebd8-4b4f-afad-4d21e340cca2(org.modelix.build.scripts)\" version=\"0\" />\n" }, { "change_type": "DELETE", "old_path": "mps/org.modelix.model/models/org.modelix.model.api.mps", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<model ref=\"r:46060cc2-3362-406a-b40d-9ba8d71212b0(org.modelix.model.api)\">\n- <persistence version=\"9\" />\n- <languages>\n- <devkit ref=\"fbc25dd2-5da4-483a-8b19-70928e1b62d7(jetbrains.mps.devkit.general-purpose)\" />\n- </languages>\n- <imports>\n- <import index=\"3hky\" ref=\"r:bef1bfa7-20fd-413a-ae11-793b0a8ee364(de.q60.mps.shadowmodels.runtime.model.persistent)\" />\n- </imports>\n- <registry>\n- <language id=\"f3061a53-9226-4cc5-a443-f952ceaf5816\" name=\"jetbrains.mps.baseLanguage\">\n- <concept id=\"1465982738277781862\" name=\"jetbrains.mps.baseLanguage.structure.PlaceholderMember\" flags=\"ng\" index=\"2tJIrI\" />\n- <concept id=\"1225271177708\" name=\"jetbrains.mps.baseLanguage.structure.StringType\" flags=\"in\" index=\"17QB3L\" />\n- <concept id=\"1068580123132\" name=\"jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration\" flags=\"ng\" index=\"3clF44\">\n- <child id=\"1068580123133\" name=\"returnType\" index=\"3clF45\" />\n- <child id=\"1068580123135\" name=\"body\" index=\"3clF47\" />\n- </concept>\n- <concept id=\"1068580123165\" name=\"jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration\" flags=\"ig\" index=\"3clFb_\" />\n- <concept id=\"1068580123136\" name=\"jetbrains.mps.baseLanguage.structure.StatementList\" flags=\"sn\" stub=\"5293379017992965193\" index=\"3clFbS\" />\n- <concept id=\"1068581242867\" name=\"jetbrains.mps.baseLanguage.structure.LongType\" flags=\"in\" index=\"3cpWsb\" />\n- <concept id=\"1107461130800\" name=\"jetbrains.mps.baseLanguage.structure.Classifier\" flags=\"ng\" index=\"3pOWGL\">\n- <child id=\"5375687026011219971\" name=\"member\" index=\"jymVt\" unordered=\"true\" />\n- </concept>\n- <concept id=\"1107535904670\" name=\"jetbrains.mps.baseLanguage.structure.ClassifierType\" flags=\"in\" index=\"3uibUv\">\n- <reference id=\"1107535924139\" name=\"classifier\" index=\"3uigEE\" />\n- </concept>\n- <concept id=\"1178549954367\" name=\"jetbrains.mps.baseLanguage.structure.IVisible\" flags=\"ng\" index=\"1B3ioH\">\n- <child id=\"1178549979242\" name=\"visibility\" index=\"1B3o_S\" />\n- </concept>\n- <concept id=\"1107796713796\" name=\"jetbrains.mps.baseLanguage.structure.Interface\" flags=\"ig\" index=\"3HP615\" />\n- <concept id=\"1146644602865\" name=\"jetbrains.mps.baseLanguage.structure.PublicVisibility\" flags=\"nn\" index=\"3Tm1VV\" />\n- </language>\n- <language id=\"ceab5195-25ea-4f22-9b92-103b95ca8c0c\" name=\"jetbrains.mps.lang.core\">\n- <concept id=\"1169194658468\" name=\"jetbrains.mps.lang.core.structure.INamedConcept\" flags=\"ng\" index=\"TrEIO\">\n- <property id=\"1169194664001\" name=\"name\" index=\"TrG5h\" />\n- </concept>\n- </language>\n- </registry>\n- <node concept=\"3HP615\" id=\"4tzwkINLh9S\">\n- <property role=\"TrG5h\" value=\"IElement\" />\n- <node concept=\"3clFb_\" id=\"4_P7CAmvu1W\" role=\"jymVt\">\n- <property role=\"TrG5h\" value=\"getTree\" />\n- <node concept=\"3uibUv\" id=\"4TPMxteXkVQ\" role=\"3clF45\">\n- <ref role=\"3uigEE\" to=\"3hky:4_SQzDOqQ5x\" resolve=\"ITree\" />\n- </node>\n- <node concept=\"3Tm1VV\" id=\"4_P7CAmvu1Z\" role=\"1B3o_S\" />\n- <node concept=\"3clFbS\" id=\"4_P7CAmvu20\" role=\"3clF47\" />\n- </node>\n- <node concept=\"3clFb_\" id=\"1SVbIFIiQ5L\" role=\"jymVt\">\n- <property role=\"TrG5h\" value=\"getParent\" />\n- <node concept=\"3uibUv\" id=\"3jzgJ0sZEXA\" role=\"3clF45\">\n- <ref role=\"3uigEE\" node=\"4tzwkINLhd2\" resolve=\"INode\" />\n- </node>\n- <node concept=\"3Tm1VV\" id=\"1SVbIFIiQ5O\" role=\"1B3o_S\" />\n- <node concept=\"3clFbS\" id=\"1SVbIFIiQ5P\" role=\"3clF47\" />\n- </node>\n- <node concept=\"3clFb_\" id=\"1SVbIFIiQ7a\" role=\"jymVt\">\n- <property role=\"TrG5h\" value=\"getRoleInParent\" />\n- <node concept=\"17QB3L\" id=\"1SVbIFIiQ8i\" role=\"3clF45\" />\n- <node concept=\"3Tm1VV\" id=\"1SVbIFIiQ7d\" role=\"1B3o_S\" />\n- <node concept=\"3clFbS\" id=\"1SVbIFIiQ7e\" role=\"3clF47\" />\n- </node>\n- <node concept=\"3clFb_\" id=\"ifAKfhPj_M\" role=\"jymVt\">\n- <property role=\"TrG5h\" value=\"getRef\" />\n- <node concept=\"3uibUv\" id=\"ifAKfhPjBa\" role=\"3clF45\">\n- <ref role=\"3uigEE\" node=\"1SVbIFIiQbN\" resolve=\"IElementRef\" />\n- </node>\n- <node concept=\"3Tm1VV\" id=\"ifAKfhPj_P\" role=\"1B3o_S\" />\n- <node concept=\"3clFbS\" id=\"ifAKfhPj_Q\" role=\"3clF47\" />\n- </node>\n- <node concept=\"3clFb_\" id=\"4TPMxtfJzds\" role=\"jymVt\">\n- <property role=\"TrG5h\" value=\"getId\" />\n- <node concept=\"3cpWsb\" id=\"4TPMxtfJzf4\" role=\"3clF45\" />\n- <node concept=\"3Tm1VV\" id=\"4TPMxtfJzdv\" role=\"1B3o_S\" />\n- <node concept=\"3clFbS\" id=\"4TPMxtfJzdw\" role=\"3clF47\" />\n- </node>\n- <node concept=\"3Tm1VV\" id=\"4tzwkINLh9T\" role=\"1B3o_S\" />\n- </node>\n- <node concept=\"3HP615\" id=\"1SVbIFIiQbN\">\n- <property role=\"TrG5h\" value=\"IElementRef\" />\n- <node concept=\"3Tm1VV\" id=\"1SVbIFIiQbO\" role=\"1B3o_S\" />\n- </node>\n- <node concept=\"3HP615\" id=\"4tzwkINLhd2\">\n- <property role=\"TrG5h\" value=\"INode\" />\n- <node concept=\"2tJIrI\" id=\"7Aj1SIwFPhQ\" role=\"jymVt\" />\n- <node concept=\"3Tm1VV\" id=\"4tzwkINLhd3\" role=\"1B3o_S\" />\n- </node>\n-</model>\n-\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Removed unnecessary dependency from org.modelix.build.scripts
426,500
18.06.2020 13:48:15
-7,200
9247a12024006884e895c73e560cf630137d65c6
Mentioned downloading MPS and installing docker.
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -15,6 +15,12 @@ In production modelix uses docker images running in a kubernetes cluster.\nDuring development you can run the different components without docker/kubernetes.\nYou need a PostgreSQL database, the model server and the MPS plugin for the UI server.\n+## Installing MPS\n+\n+While the MPS that is used for the build is downloaded automatically, you have to install MPS yourself to use it as the client. Currently we rely on MPS 2020.1 which you can get from https://www.jetbrains.com/mps/\n+\n+\n+\n## Running without kubernetes\nWhile you can install PostgreSQL locally it's easier to just run the docker image.\n@@ -22,6 +28,8 @@ This gives you an empty ready to use database each time you restart the docker i\nIf you still want to install a PostgreSQL server check the files [./db/initdb.sql](./db/initdb.sql) and\n[./model-server/src/main/resources/org/modelix/model/server/database.properties](./model-server/src/main/resources/org/modelix/model/server/database.properties).\n+- docker: you need Docker on your machine; get it from https://docs.docker.com/docker-for-mac/install/ and then run it via `docker.app`.\n+\n- database\n- Change the port in [./model-server/src/main/resources/org/modelix/model/server/database.properties](./model-server/src/main/resources/org/modelix/model/server/database.properties) to 54333 or change the port in [./docker-run-db.sh](./docker-run-db.sh) to 5432\n- `./docker-build-db.sh`\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Mentioned downloading MPS and installing docker.
426,500
18.06.2020 13:49:36
-7,200
75e1e6537b16aa074c304252810efe7df3c87f20
Mentioned cloning the repo.
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -8,13 +8,16 @@ The modelix project develops a next generation language workbench that is native\n* Database/Cloud storage for MPS models with realtime collaboration\n* Server-based execution of MPS and browser-based editors\n-\n# How to run modelix\nIn production modelix uses docker images running in a kubernetes cluster.\nDuring development you can run the different components without docker/kubernetes.\nYou need a PostgreSQL database, the model server and the MPS plugin for the UI server.\n+## Clone the repo\n+\n+Obviously you first have to clone this repository. At this time there are no builds or releases available.\n+\n## Installing MPS\nWhile the MPS that is used for the build is downloaded automatically, you have to install MPS yourself to use it as the client. Currently we rely on MPS 2020.1 which you can get from https://www.jetbrains.com/mps/\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Mentioned cloning the repo.
426,500
18.06.2020 13:50:37
-7,200
3aa01e83457cb46bb0f52b87b9fad92077b9afe2
Reformulated the port change thingy to make it clearer
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -34,7 +34,7 @@ If you still want to install a PostgreSQL server check the files [./db/initdb.sq\n- docker: you need Docker on your machine; get it from https://docs.docker.com/docker-for-mac/install/ and then run it via `docker.app`.\n- database\n- - Change the port in [./model-server/src/main/resources/org/modelix/model/server/database.properties](./model-server/src/main/resources/org/modelix/model/server/database.properties) to 54333 or change the port in [./docker-run-db.sh](./docker-run-db.sh) to 5432\n+ - Change the port in [./model-server/src/main/resources/org/modelix/model/server/database.properties](./model-server/src/main/resources/org/modelix/model/server/database.properties) to 54333; that number is then mentioned twice, before and after the colon\n- `./docker-build-db.sh`\n- `./docker-run-db.sh`\n- model server\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Reformulated the port change thingy to make it clearer
426,496
18.06.2020 13:57:12
-7,200
f9dcbc22c7766020ec4067dc4557720f76137596
Deleted dead code from org.modelix.model
[ { "change_type": "DELETE", "old_path": "mps/org.modelix.model/models/org.modelix.model.api2.mps", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<model ref=\"r:da7cf74a-6366-4cd3-81fd-87283980def8(org.modelix.model.api2)\">\n- <persistence version=\"9\" />\n- <languages />\n- <imports />\n- <registry />\n-</model>\n-\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model/models/org.modelix.model.lazy.mps", "new_path": "mps/org.modelix.model/models/org.modelix.model.lazy.mps", "diff": "<import index=\"mhfm\" ref=\"3f233e7f-b8a6-46d2-a57f-795d56775243/java:org.jetbrains.annotations(Annotations/)\" />\n<import index=\"wyt6\" ref=\"6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)\" />\n<import index=\"6shs\" ref=\"r:3ca2f5b1-1b25-441b-b059-2ddba424a0b1(org.modelix.model.persistent)\" />\n- <import index=\"kxbk\" ref=\"r:46060cc2-3362-406a-b40d-9ba8d71212b0(org.modelix.model.api)\" />\n<import index=\"3hky\" ref=\"r:bef1bfa7-20fd-413a-ae11-793b0a8ee364(de.q60.mps.shadowmodels.runtime.model.persistent)\" />\n<import index=\"l6bp\" ref=\"r:97875f9c-321e-405e-a344-6d3deab2bdba(de.q60.mps.shadowmodels.runtime.smodel)\" />\n<import index=\"w1kc\" ref=\"6ed54515-acc8-4d1e-a16c-9fd6cfe951ea/java:jetbrains.mps.smodel(MPS.Core/)\" />\n</node>\n</node>\n</node>\n- <node concept=\"2AHcQZ\" id=\"4TPMxtfJzKc\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"wyt6:~Override\" resolve=\"Override\" />\n- </node>\n</node>\n<node concept=\"2tJIrI\" id=\"ifAKfhZ7tA\" role=\"jymVt\" />\n<node concept=\"3clFb_\" id=\"4_P7CAmvu$r\" role=\"jymVt\">\n</node>\n</node>\n</node>\n- <node concept=\"2AHcQZ\" id=\"4_P7CAmvu$w\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"wyt6:~Override\" resolve=\"Override\" />\n- </node>\n</node>\n<node concept=\"2tJIrI\" id=\"4_P7CAmvv3h\" role=\"jymVt\" />\n<node concept=\"3clFb_\" id=\"ifAKfhQ3Zh\" role=\"jymVt\">\n</node>\n</node>\n</node>\n- <node concept=\"2AHcQZ\" id=\"ifAKfhQ3Zm\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"wyt6:~Override\" resolve=\"Override\" />\n- </node>\n</node>\n<node concept=\"2tJIrI\" id=\"ifAKfhQ44x\" role=\"jymVt\" />\n<node concept=\"3clFb_\" id=\"ifAKfhQ3Zp\" role=\"jymVt\">\n</node>\n</node>\n</node>\n- <node concept=\"2AHcQZ\" id=\"ifAKfhQ3Zu\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"wyt6:~Override\" resolve=\"Override\" />\n- </node>\n</node>\n<node concept=\"2tJIrI\" id=\"ifAKfhQ48d\" role=\"jymVt\" />\n<node concept=\"3clFb_\" id=\"ifAKfhQ3Zv\" role=\"jymVt\">\n<property role=\"1EzhhJ\" value=\"false\" />\n<property role=\"TrG5h\" value=\"getRef\" />\n- <node concept=\"3uibUv\" id=\"ifAKfhQ3Zw\" role=\"3clF45\">\n- <ref role=\"3uigEE\" to=\"kxbk:1SVbIFIiQbN\" resolve=\"IElementRef\" />\n+ <node concept=\"3uibUv\" id=\"4cICdleaeYE\" role=\"3clF45\">\n+ <ref role=\"3uigEE\" node=\"ifAKfhPj$U\" resolve=\"CLElementRef\" />\n</node>\n<node concept=\"3Tm1VV\" id=\"ifAKfhQ3Zx\" role=\"1B3o_S\" />\n<node concept=\"3clFbS\" id=\"ifAKfhQ3Zz\" role=\"3clF47\">\n</node>\n</node>\n</node>\n- <node concept=\"2AHcQZ\" id=\"ifAKfhQ3Z$\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"wyt6:~Override\" resolve=\"Override\" />\n- </node>\n- </node>\n- <node concept=\"3uibUv\" id=\"6sqLxIGDetF\" role=\"EKbjA\">\n- <ref role=\"3uigEE\" to=\"kxbk:4tzwkINLh9S\" resolve=\"IElement\" />\n</node>\n</node>\n<node concept=\"312cEu\" id=\"ifAKfhPj$U\">\n</node>\n<node concept=\"2tJIrI\" id=\"ifAKfhPjCv\" role=\"jymVt\" />\n<node concept=\"3Tm1VV\" id=\"ifAKfhPj$V\" role=\"1B3o_S\" />\n- <node concept=\"3uibUv\" id=\"ifAKfhPj_B\" role=\"EKbjA\">\n- <ref role=\"3uigEE\" to=\"kxbk:1SVbIFIiQbN\" resolve=\"IElementRef\" />\n- </node>\n<node concept=\"3clFb_\" id=\"ifAKfhPjCN\" role=\"jymVt\">\n<property role=\"TrG5h\" value=\"getId\" />\n<node concept=\"3cpWsb\" id=\"ifAKfhPjCO\" role=\"3clF45\" />\n<node concept=\"3uibUv\" id=\"3iPRerNOGdz\" role=\"1zkMxy\">\n<ref role=\"3uigEE\" node=\"1SVbIFIj0Y2\" resolve=\"CLElement\" />\n</node>\n- <node concept=\"3uibUv\" id=\"ifAKfhQl3q\" role=\"EKbjA\">\n- <ref role=\"3uigEE\" to=\"kxbk:4tzwkINLhd2\" resolve=\"INode\" />\n- </node>\n</node>\n<node concept=\"312cEu\" id=\"1SVbIFIiXt2\">\n<property role=\"TrG5h\" value=\"CLTree\" />\n<property role=\"1EzhhJ\" value=\"false\" />\n<property role=\"TrG5h\" value=\"resolveElement\" />\n<node concept=\"37vLTG\" id=\"ifAKfhPhGy\" role=\"3clF46\">\n- <property role=\"TrG5h\" value=\"ref_\" />\n- <node concept=\"3uibUv\" id=\"ifAKfhPhGz\" role=\"1tU5fm\">\n- <ref role=\"3uigEE\" to=\"kxbk:1SVbIFIiQbN\" resolve=\"IElementRef\" />\n+ <property role=\"TrG5h\" value=\"ref\" />\n+ <node concept=\"3uibUv\" id=\"4cICdleasbR\" role=\"1tU5fm\">\n+ <ref role=\"3uigEE\" node=\"ifAKfhPj$U\" resolve=\"CLElementRef\" />\n</node>\n</node>\n<node concept=\"3uibUv\" id=\"7Aj1SIwHIYC\" role=\"3clF45\">\n<node concept=\"3clFbC\" id=\"ifAKfhQpYz\" role=\"3clFbw\">\n<node concept=\"10Nm6u\" id=\"ifAKfhQqiF\" role=\"3uHU7w\" />\n<node concept=\"37vLTw\" id=\"ifAKfhQp_g\" role=\"3uHU7B\">\n- <ref role=\"3cqZAo\" node=\"ifAKfhPhGy\" resolve=\"ref_\" />\n+ <ref role=\"3cqZAo\" node=\"ifAKfhPhGy\" resolve=\"ref\" />\n</node>\n</node>\n</node>\n<property role=\"TrG5h\" value=\"id\" />\n<node concept=\"3cpWsb\" id=\"ifAKfhPnyl\" role=\"1tU5fm\" />\n<node concept=\"2OqwBi\" id=\"ifAKfhPnyq\" role=\"33vP2m\">\n- <node concept=\"1eOMI4\" id=\"ifAKfhPnyr\" role=\"2Oq$k0\">\n- <node concept=\"10QFUN\" id=\"ifAKfhPnys\" role=\"1eOMHV\">\n- <node concept=\"37vLTw\" id=\"ifAKfhPnyt\" role=\"10QFUP\">\n- <ref role=\"3cqZAo\" node=\"ifAKfhPhGy\" resolve=\"ref_\" />\n- </node>\n- <node concept=\"3uibUv\" id=\"ifAKfhPnyu\" role=\"10QFUM\">\n- <ref role=\"3uigEE\" node=\"ifAKfhPj$U\" resolve=\"CLElementRef\" />\n- </node>\n- </node>\n+ <node concept=\"37vLTw\" id=\"4cICdleatPm\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"ifAKfhPhGy\" resolve=\"ref\" />\n</node>\n<node concept=\"liA8E\" id=\"ifAKfhPnyv\" role=\"2OqNvi\">\n<ref role=\"37wK5l\" node=\"ifAKfhPjCN\" resolve=\"getId\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Deleted dead code from org.modelix.model
426,496
18.06.2020 19:42:16
-7,200
bb6cecc152b92aecefca1a4db993b03b90e58a73
Update .travis.yml to use java 11
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "language: java\ninstall: true\n-jdk: openjdk8\n+jdk: openjdk11\nscript:\n- ./gradlew\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "-<a href=\"https://build.mbeddr.com/project.html?projectId=WebMps_WebMpsBuild&tab=projectOverview\"><img src=\"http://build.mbeddr.com/app/rest/builds/buildType:(id:WebMps_WebMpsBuild)/statusIcon\"/></a>\n+[![Build Status](https://travis-ci.org/modelix/modelix.svg?branch=master)](https://travis-ci.org/modelix/modelix) <a href=\"https://build.mbeddr.com/project.html?projectId=WebMps_WebMpsBuild&tab=projectOverview\"><img src=\"http://build.mbeddr.com/app/rest/builds/buildType:(id:WebMps_WebMpsBuild)/statusIcon\"/></a>\n# The modelix Project\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Update .travis.yml to use java 11
426,496
19.06.2020 14:32:12
-7,200
0aa7ec41cf200692dea607d114577e53f25174a0
Migration to kubernetes >= 1.16 Fixes
[ { "change_type": "MODIFY", "old_path": "kubernetes/common/model-deployment.yaml", "new_path": "kubernetes/common/model-deployment.yaml", "diff": "-apiVersion: extensions/v1beta1\n+apiVersion: apps/v1\nkind: Deployment\nmetadata:\nannotations:\n@@ -14,6 +14,9 @@ spec:\nrollingUpdate:\nmaxUnavailable: 1\nmaxSurge: 0\n+ selector:\n+ matchLabels:\n+ app: model\ntemplate:\nmetadata:\ncreationTimestamp: null\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/common/oauth-deployment.yaml", "new_path": "kubernetes/common/oauth-deployment.yaml", "diff": "-apiVersion: extensions/v1beta1\n+apiVersion: apps/v1\nkind: Deployment\nmetadata:\nlabels:\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/common/pgadmin-deployment.yaml", "new_path": "kubernetes/common/pgadmin-deployment.yaml", "diff": "-apiVersion: extensions/v1beta1\n+apiVersion: apps/v1\nkind: Deployment\nmetadata:\nannotations:\n@@ -9,6 +9,9 @@ metadata:\nspec:\nreplicas: 1\nstrategy: {}\n+ selector:\n+ matchLabels:\n+ app: pgadmin\ntemplate:\nmetadata:\ncreationTimestamp: null\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/common/proxy-deployment.yaml", "new_path": "kubernetes/common/proxy-deployment.yaml", "diff": "-apiVersion: extensions/v1beta1\n+apiVersion: apps/v1\nkind: Deployment\nmetadata:\nannotations:\n@@ -14,6 +14,9 @@ spec:\nrollingUpdate:\nmaxUnavailable: 0\nmaxSurge: 1\n+ selector:\n+ matchLabels:\n+ app: proxy\ntemplate:\nmetadata:\ncreationTimestamp: null\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/common/ui-deployment.yaml", "new_path": "kubernetes/common/ui-deployment.yaml", "diff": "-apiVersion: extensions/v1beta1\n+apiVersion: apps/v1\nkind: Deployment\nmetadata:\nannotations:\n@@ -14,6 +14,9 @@ spec:\nrollingUpdate:\nmaxUnavailable: 0\nmaxSurge: 1\n+ selector:\n+ matchLabels:\n+ app: ui\ntemplate:\nmetadata:\ncreationTimestamp: null\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/local/db-deployment.yaml", "new_path": "kubernetes/local/db-deployment.yaml", "diff": "-apiVersion: extensions/v1beta1\n+apiVersion: apps/v1\nkind: Deployment\nmetadata:\nannotations:\n@@ -10,6 +10,9 @@ spec:\nreplicas: 1\nstrategy:\ntype: Recreate\n+ selector:\n+ matchLabels:\n+ app: db\ntemplate:\nmetadata:\ncreationTimestamp: null\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Migration to kubernetes >= 1.16 Fixes #6
426,496
19.06.2020 15:48:17
-7,200
bc13d347e96f3b98fff46d0ab6384dd5ce63e7a3
UI health check that doesn't rely on existing data on the model server The previous health check was checking the SRepository for exisiting cloud modules. In a new cluster, there are no modules on the model server. Now the database connection is directly checked.
[ { "change_type": "MODIFY", "old_path": "docker-build-db.sh", "new_path": "docker-build-db.sh", "diff": "#!/bin/sh\ncd db\n-docker build -f Dockerfile -t modelix-db .\n\\ No newline at end of file\n+docker build --no-cache -f Dockerfile -t modelix-db .\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "docker-push-hub.sh", "new_path": "docker-push-hub.sh", "diff": "@@ -30,9 +30,11 @@ docker push \"modelix/modelix-proxy:latest\"\necho \"Pushed tag ${TAG}\"\n+sed -i -E \"s/20[12][0-9][01][0-9][0123][0-9][0-5][0-9][0-5][0-9]/${TAG}/\" kubernetes/local/db-deployment.yaml\nsed -i -E \"s/20[12][0-9][01][0-9][0123][0-9][0-5][0-9][0-5][0-9]/${TAG}/\" kubernetes/common/ui-deployment.yaml\nsed -i -E \"s/20[12][0-9][01][0-9][0123][0-9][0-5][0-9][0-5][0-9]/${TAG}/\" kubernetes/common/model-deployment.yaml\nsed -i -E \"s/20[12][0-9][01][0-9][0123][0-9][0-5][0-9][0-5][0-9]/${TAG}/\" kubernetes/common/proxy-deployment.yaml\n+rm kubernetes/local/db-deployment.yaml-E\nrm kubernetes/common/ui-deployment.yaml-E\nrm kubernetes/common/model-deployment.yaml-E\nrm kubernetes/common/proxy-deployment.yaml-E\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/common/model-deployment.yaml", "new_path": "kubernetes/common/model-deployment.yaml", "diff": "@@ -8,7 +8,7 @@ metadata:\nname: model\nspec:\nrevisionHistoryLimit: 5\n- replicas: 3\n+ replicas: 1\nstrategy:\ntype: RollingUpdate\nrollingUpdate:\n@@ -27,7 +27,7 @@ spec:\n- env:\n- name: jdbc_url\nvalue: jdbc:postgresql://db:5432/\n- image: modelix/modelix-model:202006161724\n+ image: modelix/modelix-model:202006191556\nimagePullPolicy: IfNotPresent\nname: model\nports:\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/common/proxy-deployment.yaml", "new_path": "kubernetes/common/proxy-deployment.yaml", "diff": "@@ -25,7 +25,7 @@ spec:\nspec:\ncontainers:\n- name: proxy\n- image: modelix/modelix-proxy:202006161724\n+ image: modelix/modelix-proxy:202006191556\nimagePullPolicy: IfNotPresent\nenv:\nports:\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/common/ui-deployment.yaml", "new_path": "kubernetes/common/ui-deployment.yaml", "diff": "@@ -25,7 +25,7 @@ spec:\nspec:\ncontainers:\n- name: ui\n- image: modelix/modelix-ui:202006161724\n+ image: modelix/modelix-ui:202006191556\nimagePullPolicy: IfNotPresent\nenv:\n- name: MODEL_URI\n" }, { "change_type": "MODIFY", "old_path": "kubernetes/local/db-deployment.yaml", "new_path": "kubernetes/local/db-deployment.yaml", "diff": "@@ -29,7 +29,7 @@ spec:\nvalue: modelix\n- name: PGDATA\nvalue: /var/lib/postgresql/data/pgdata\n- image: modelix/modelix-db\n+ image: modelix/modelix-db:202006191556\nimagePullPolicy: IfNotPresent\nname: db\nresources: {}\n" }, { "change_type": "MODIFY", "old_path": "model-server/Dockerfile", "new_path": "model-server/Dockerfile", "diff": "FROM openjdk:11\nWORKDIR /usr/modelix-model\n-EXPOSE 63320\n+EXPOSE 28101\nCOPY run-model-server.sh /usr/modelix-model/\nCOPY build/ /usr/modelix-model/model-server/build/\nCMD [\"./run-model-server.sh\"]\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.build/models/org.modelix.build.mps", "new_path": "mps/org.modelix.build/models/org.modelix.build.mps", "diff": "</node>\n</node>\n</node>\n+ <node concept=\"1SiIV0\" id=\"4cICdlebXxQ\" role=\"3bR37C\">\n+ <node concept=\"3bR9La\" id=\"4cICdlebXxR\" role=\"1SiIV1\">\n+ <ref role=\"3bR37D\" node=\"7gF2HTviNPK\" resolve=\"org.modelix.model\" />\n+ </node>\n+ </node>\n</node>\n</node>\n<node concept=\"2G$12M\" id=\"7gF2HTviNPV\" role=\"3989C9\">\n<node concept=\"3LEDTy\" id=\"7BujJjYSJ9v\" role=\"3LEDUa\">\n<ref role=\"3LEDTV\" node=\"7gF2HTviNPn\" resolve=\"org.modelix.ui.sm\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"4tfK3zZNUpm\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L9c\" resolve=\"jetbrains.mps.lang.quotation\" />\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_t\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5Hg\" resolve=\"de.q60.mps.shadowmodels.gen.afterPF\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_u\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L0h\" resolve=\"jetbrains.mps.baseLanguage.collections\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_v\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZG\" resolve=\"jetbrains.mps.baseLanguage.closures\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_w\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5HO\" resolve=\"de.q60.mps.shadowmodels.transformation\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_x\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZ0\" resolve=\"jetbrains.mps.baseLanguageInternal\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_y\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L9O\" resolve=\"jetbrains.mps.lang.smodel\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_z\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L2l\" resolve=\"jetbrains.mps.baseLanguage.logging\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_$\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:14x5$qAUbkb\" resolve=\"jetbrains.mps.lang.access\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX__\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L4j\" resolve=\"jetbrains.mps.lang.actions\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_A\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"90a9:7c10t$7lQIA\" resolve=\"de.q60.mps.shadowmodels.gen.typesystem\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_B\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L2F\" resolve=\"jetbrains.mps.baseLanguage.tuples\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_C\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5Hs\" resolve=\"de.q60.mps.polymorphicfunctions\" />\n+ </node>\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_D\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"90a9:2$QnGbtLXzL\" resolve=\"de.q60.mps.shadowmodels.gen.desugar\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"4tfK3zZNUpn\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZc\" resolve=\"jetbrains.mps.baseLanguage.checkedDots\" />\n+ <node concept=\"3LEDTy\" id=\"4cICdlebX_E\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KYb\" resolve=\"jetbrains.mps.baseLanguage\" />\n</node>\n</node>\n<node concept=\"1E1JtD\" id=\"7BujJjXYVmv\" role=\"2G$12L\">\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.server/models/org.modelix.ui.server.plugin.mps", "new_path": "mps/org.modelix.ui.server/models/org.modelix.ui.server.plugin.mps", "diff": "<concept id=\"1203518072036\" name=\"jetbrains.mps.baseLanguage.collections.structure.SmartClosureParameterDeclaration\" flags=\"ig\" index=\"Rh6nW\" />\n<concept id=\"1160600644654\" name=\"jetbrains.mps.baseLanguage.collections.structure.ListCreatorWithInit\" flags=\"nn\" index=\"Tc6Ow\" />\n<concept id=\"1160612413312\" name=\"jetbrains.mps.baseLanguage.collections.structure.AddElementOperation\" flags=\"nn\" index=\"TSZUe\" />\n- <concept id=\"4611582986551314327\" name=\"jetbrains.mps.baseLanguage.collections.structure.OfTypeOperation\" flags=\"nn\" index=\"UnYns\">\n- <child id=\"4611582986551314344\" name=\"requestedType\" index=\"UnYnz\" />\n- </concept>\n<concept id=\"1160666733551\" name=\"jetbrains.mps.baseLanguage.collections.structure.AddAllElementsOperation\" flags=\"nn\" index=\"X8dFx\" />\n<concept id=\"1201792049884\" name=\"jetbrains.mps.baseLanguage.collections.structure.TranslateOperation\" flags=\"nn\" index=\"3goQfb\" />\n<concept id=\"1197683403723\" name=\"jetbrains.mps.baseLanguage.collections.structure.MapType\" flags=\"in\" index=\"3rvAFt\">\n<node concept=\"3clFbH\" id=\"2TMlwYi2E7p\" role=\"3cqZAp\" />\n<node concept=\"3J1_TO\" id=\"2TMlwYi2CCK\" role=\"3cqZAp\">\n<node concept=\"3clFbS\" id=\"2TMlwYi2CCM\" role=\"1zxBo7\">\n- <node concept=\"3cpWs8\" id=\"QucyCqZCkH\" role=\"3cqZAp\">\n- <node concept=\"3cpWsn\" id=\"QucyCqZCkI\" role=\"3cpWs9\">\n+ <node concept=\"2Gpval\" id=\"4cICdlebhqk\" role=\"3cqZAp\">\n+ <node concept=\"2GrKxI\" id=\"4cICdlebhqm\" role=\"2Gsz3X\">\n<property role=\"TrG5h\" value=\"repo\" />\n- <node concept=\"3uibUv\" id=\"QucyCqZC0Q\" role=\"1tU5fm\">\n- <ref role=\"3uigEE\" to=\"w1kc:~MPSModuleRepository\" resolve=\"MPSModuleRepository\" />\n- </node>\n- <node concept=\"2YIFZM\" id=\"QucyCqZCkJ\" role=\"33vP2m\">\n- <ref role=\"37wK5l\" to=\"w1kc:~MPSModuleRepository.getInstance()\" resolve=\"getInstance\" />\n- <ref role=\"1Pybhc\" to=\"w1kc:~MPSModuleRepository\" resolve=\"MPSModuleRepository\" />\n- </node>\n- </node>\n- </node>\n- <node concept=\"3clFbF\" id=\"QucyCqZCCq\" role=\"3cqZAp\">\n- <node concept=\"2OqwBi\" id=\"QucyCqZFlN\" role=\"3clFbG\">\n- <node concept=\"2OqwBi\" id=\"QucyCqZDcu\" role=\"2Oq$k0\">\n- <node concept=\"37vLTw\" id=\"QucyCqZCCo\" role=\"2Oq$k0\">\n- <ref role=\"3cqZAo\" node=\"QucyCqZCkI\" resolve=\"repo\" />\n- </node>\n- <node concept=\"liA8E\" id=\"QucyCqZFdK\" role=\"2OqNvi\">\n- <ref role=\"37wK5l\" to=\"w1kc:~MPSModuleRepository.getModelAccess()\" resolve=\"getModelAccess\" />\n- </node>\n- </node>\n- <node concept=\"liA8E\" id=\"QucyCqZFwP\" role=\"2OqNvi\">\n- <ref role=\"37wK5l\" to=\"lui2:~ModelAccess.runReadAction(java.lang.Runnable)\" resolve=\"runReadAction\" />\n- <node concept=\"1bVj0M\" id=\"QucyCqZFBQ\" role=\"37wK5m\">\n- <node concept=\"3clFbS\" id=\"QucyCqZFBR\" role=\"1bW5cS\">\n- <node concept=\"3cpWs8\" id=\"QucyCqZhXe\" role=\"3cqZAp\">\n- <node concept=\"3cpWsn\" id=\"QucyCqZhXf\" role=\"3cpWs9\">\n- <property role=\"TrG5h\" value=\"modules\" />\n- <node concept=\"A3Dl8\" id=\"QucyCqZiiY\" role=\"1tU5fm\">\n- <node concept=\"3uibUv\" id=\"QucyCqZij0\" role=\"A3Ik2\">\n- <ref role=\"3uigEE\" to=\"lui2:~SModule\" resolve=\"SModule\" />\n- </node>\n- </node>\n- <node concept=\"2OqwBi\" id=\"QucyCqZhXg\" role=\"33vP2m\">\n- <node concept=\"37vLTw\" id=\"QucyCqZCkK\" role=\"2Oq$k0\">\n- <ref role=\"3cqZAo\" node=\"QucyCqZCkI\" resolve=\"repo\" />\n- </node>\n- <node concept=\"liA8E\" id=\"QucyCqZhXi\" role=\"2OqNvi\">\n- <ref role=\"37wK5l\" to=\"w1kc:~MPSModuleRepository.getModules()\" resolve=\"getModules\" />\n- </node>\n</node>\n+ <node concept=\"3clFbS\" id=\"4cICdlebhqq\" role=\"2LFqv$\">\n+ <node concept=\"3clFbJ\" id=\"4cICdlebGPH\" role=\"3cqZAp\">\n+ <node concept=\"3clFbS\" id=\"4cICdlebGPJ\" role=\"3clFbx\">\n+ <node concept=\"3clFbF\" id=\"4cICdlebIOR\" role=\"3cqZAp\">\n+ <node concept=\"37vLTI\" id=\"4cICdlebJl4\" role=\"3clFbG\">\n+ <node concept=\"3clFbT\" id=\"4cICdlebJxz\" role=\"37vLTx\" />\n+ <node concept=\"37vLTw\" id=\"4cICdlebIOP\" role=\"37vLTJ\">\n+ <ref role=\"3cqZAo\" node=\"QucyCqZDKP\" resolve=\"healthy\" />\n</node>\n</node>\n- <node concept=\"3clFbJ\" id=\"QucyCqZksk\" role=\"3cqZAp\">\n- <node concept=\"3clFbS\" id=\"QucyCqZksm\" role=\"3clFbx\">\n- <node concept=\"3clFbF\" id=\"QucyCqZGc_\" role=\"3cqZAp\">\n- <node concept=\"37vLTI\" id=\"QucyCqZGAX\" role=\"3clFbG\">\n- <node concept=\"3clFbT\" id=\"QucyCqZGHP\" role=\"37vLTx\" />\n- <node concept=\"37vLTw\" id=\"QucyCqZGcy\" role=\"37vLTJ\">\n- <ref role=\"3cqZAo\" node=\"QucyCqZDKP\" resolve=\"healthy\" />\n</node>\n</node>\n+ <node concept=\"3clFbC\" id=\"4cICdlebHmy\" role=\"3clFbw\">\n+ <node concept=\"3cmrfG\" id=\"4cICdlebHIM\" role=\"3uHU7w\">\n+ <property role=\"3cmrfH\" value=\"0\" />\n</node>\n+ <node concept=\"2OqwBi\" id=\"4cICdlebKaG\" role=\"3uHU7B\">\n+ <node concept=\"2OqwBi\" id=\"4cICdlebGUY\" role=\"2Oq$k0\">\n+ <node concept=\"2GrUjf\" id=\"4cICdlebGUZ\" role=\"2Oq$k0\">\n+ <ref role=\"2Gs0qQ\" node=\"4cICdlebhqm\" resolve=\"repo\" />\n</node>\n- <node concept=\"2OqwBi\" id=\"QucyCqZjzH\" role=\"3clFbw\">\n- <node concept=\"2OqwBi\" id=\"QucyCqZizU\" role=\"2Oq$k0\">\n- <node concept=\"37vLTw\" id=\"QucyCqZhXj\" role=\"2Oq$k0\">\n- <ref role=\"3cqZAo\" node=\"QucyCqZhXf\" resolve=\"modules\" />\n+ <node concept=\"liA8E\" id=\"4cICdlebGV0\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"csg2:2n9Wvfbnqym\" resolve=\"getClient\" />\n</node>\n- <node concept=\"UnYns\" id=\"QucyCqZj3m\" role=\"2OqNvi\">\n- <node concept=\"3uibUv\" id=\"QucyCqZji6\" role=\"UnYnz\">\n- <ref role=\"3uigEE\" to=\"csg2:115Xaa43tZI\" resolve=\"CloudTransientModule\" />\n</node>\n+ <node concept=\"liA8E\" id=\"4cICdlebKM9\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"csg2:64iiug7VnKl\" resolve=\"getClientId\" />\n</node>\n</node>\n- <node concept=\"1v1jN8\" id=\"QucyCqZk4R\" role=\"2OqNvi\" />\n</node>\n</node>\n</node>\n+ <node concept=\"2OqwBi\" id=\"4cICdlebhCM\" role=\"2GsD0m\">\n+ <node concept=\"2YIFZM\" id=\"4cICdlebhCN\" role=\"2Oq$k0\">\n+ <ref role=\"1Pybhc\" to=\"csg2:1LVcV5Kxxi$\" resolve=\"CloudRepositories\" />\n+ <ref role=\"37wK5l\" to=\"csg2:1LVcV5Kxxmz\" resolve=\"getInstance\" />\n</node>\n+ <node concept=\"liA8E\" id=\"4cICdlebhCO\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"csg2:1LVcV5KxBgM\" resolve=\"getRepositories\" />\n</node>\n</node>\n</node>\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.server/org.modelix.ui.server.msd", "new_path": "mps/org.modelix.ui.server/org.modelix.ui.server.msd", "diff": "<dependency reexport=\"false\">c5e5433e-201f-43e2-ad14-a6cba8c80cd6(org.modelix.model.mpsplugin)</dependency>\n<dependency reexport=\"false\">f3061a53-9226-4cc5-a443-f952ceaf5816(jetbrains.mps.baseLanguage)</dependency>\n<dependency reexport=\"false\">78874af2-5dd2-42a7-a21d-42fab3737d1d(org.modelix.ui.sm)</dependency>\n+ <dependency reexport=\"false\">5622e615-959d-4843-9df6-ef04ee578c18(org.modelix.model)</dependency>\n</dependencies>\n<languageVersions>\n<language slang=\"l:bc963c22-d419-49b6-8543-ea411eb9d3a1:de.q60.mps.polymorphicfunctions\" version=\"0\" />\n<module reference=\"9ded098b-ad6a-4657-bfd9-48636cfe8bc3(jetbrains.mps.lang.traceable)\" version=\"0\" />\n<module reference=\"fc3c2aa8-0d4b-463f-a774-40d450aa04a0(org.modelix.jetty)\" version=\"0\" />\n<module reference=\"87f4b21e-a3a5-459e-a54b-408fd9eb7350(org.modelix.lib)\" version=\"0\" />\n+ <module reference=\"5622e615-959d-4843-9df6-ef04ee578c18(org.modelix.model)\" version=\"0\" />\n<module reference=\"c5e5433e-201f-43e2-ad14-a6cba8c80cd6(org.modelix.model.mpsplugin)\" version=\"0\" />\n<module reference=\"39aab22b-473f-4e44-b037-0c602964897d(org.modelix.ui.server)\" version=\"0\" />\n<module reference=\"78874af2-5dd2-42a7-a21d-42fab3737d1d(org.modelix.ui.sm)\" version=\"1\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
UI health check that doesn't rely on existing data on the model server The previous health check was checking the SRepository for exisiting cloud modules. In a new cluster, there are no modules on the model server. Now the database connection is directly checked.
426,496
20.06.2020 08:48:50
-7,200
3ee8f0ae547dda62d3b6e96bd911b9105ea59d40
Renaming in docker related files in the sample projects
[ { "change_type": "MODIFY", "old_path": "samples/entities/Dockerfile", "new_path": "samples/entities/Dockerfile", "diff": "-FROM cloudmps/cloudmps-ui\n-WORKDIR /usr/cloudmps-ui\n+FROM modelix/modelix-ui\n+WORKDIR /usr/modelix-ui\n-COPY build/artifacts/org.modelix.samples.entities/org.modelix.samples.entities.zip /usr/cloudmps-ui/tmp.zip\n-RUN unzip /usr/cloudmps-ui/tmp.zip -d /usr/cloudmps-ui/mps/plugins/ && rm /usr/cloudmps-ui/tmp.zip\n+COPY build/artifacts/org.modelix.samples.entities/org.modelix.samples.entities.zip /usr/modelix-ui/tmp.zip\n+RUN unzip /usr/modelix-ui/tmp.zip -d /usr/modelix-ui/mps/plugins/ && rm /usr/modelix-ui/tmp.zip\n" }, { "change_type": "MODIFY", "old_path": "samples/entities/deployment.yaml", "new_path": "samples/entities/deployment.yaml", "diff": "@@ -22,7 +22,7 @@ spec:\nspec:\ncontainers:\n- name: entities\n- image: cloudmps/cloudmps-entities:202002041321\n+ image: modelix/modelix-entities:202002041321\nimagePullPolicy: IfNotPresent\nenv:\n- name: MODEL_URI\n" }, { "change_type": "MODIFY", "old_path": "samples/entities/docker-build.sh", "new_path": "samples/entities/docker-build.sh", "diff": "#!/bin/sh\n-docker build --no-cache -f Dockerfile -t cloudmps-entities .\n\\ No newline at end of file\n+docker build --no-cache -f Dockerfile -t modelix-entities .\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "samples/entities/docker-push.sh", "new_path": "samples/entities/docker-push.sh", "diff": "@@ -4,10 +4,10 @@ TAG=$(date +\"%Y%m%d%H%M\")\necho \"Pushing tag ${TAG}\"\n-docker tag cloudmps-entities:latest \"cloudmps/cloudmps-entities:${TAG}\"\n-docker push \"cloudmps/cloudmps-entities:${TAG}\"\n-docker tag cloudmps-entities:latest \"cloudmps/cloudmps-entities:latest\"\n-docker push \"cloudmps/cloudmps-entities:latest\"\n+docker tag modelix-entities:latest \"modelix/modelix-entities:${TAG}\"\n+docker push \"modelix/modelix-entities:${TAG}\"\n+docker tag modelix-entities:latest \"modelix/modelix-entities:latest\"\n+docker push \"modelix/modelix-entities:latest\"\nsed -i -E \"s/20[12][0-9][01][0-9][0123][0-9][0-5][0-9][0-5][0-9]/${TAG}/\" deployment.yaml\nrm deployment.yaml-E\n" }, { "change_type": "MODIFY", "old_path": "samples/iets3/Dockerfile", "new_path": "samples/iets3/Dockerfile", "diff": "-FROM cloudmps/cloudmps-ui\n-WORKDIR /usr/cloudmps-ui\n+FROM modelix/modelix-ui\n+WORKDIR /usr/modelix-ui\n-COPY artifacts/com.mbeddr.platform/ /usr/cloudmps-ui/mps/plugins/\n-COPY artifacts/org.iets3.opensource/ /usr/cloudmps-ui/mps/plugins/\n+COPY artifacts/com.mbeddr.platform/ /usr/modelix-ui/mps/plugins/\n+COPY artifacts/org.iets3.opensource/ /usr/modelix-ui/mps/plugins/\n" }, { "change_type": "MODIFY", "old_path": "samples/iets3/docker-build.sh", "new_path": "samples/iets3/docker-build.sh", "diff": "#!/bin/sh\n-docker build --no-cache -f Dockerfile -t cloudmps-iets3 .\n\\ No newline at end of file\n+docker build --no-cache -f Dockerfile -t modelix-iets3 .\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "samples/iets3/docker-push.sh", "new_path": "samples/iets3/docker-push.sh", "diff": "@@ -4,10 +4,10 @@ TAG=$(date +\"%Y%m%d%H%M\")\necho \"Pushing tag ${TAG}\"\n-docker tag cloudmps-iets3:latest \"cloudmps/cloudmps-iets3:${TAG}\"\n-docker push \"cloudmps/cloudmps-iets3:${TAG}\"\n-docker tag cloudmps-iets3:latest \"cloudmps/cloudmps-iets3:latest\"\n-docker push \"cloudmps/cloudmps-iets3:latest\"\n+docker tag modelix-iets3:latest \"modelix/modelix-iets3:${TAG}\"\n+docker push \"modelix/modelix-iets3:${TAG}\"\n+docker tag modelix-iets3:latest \"modelix/modelix-iets3:latest\"\n+docker push \"modelix/modelix-iets3:latest\"\n#sed -i -E \"s/20[12][0-9][01][0-9][0123][0-9][0-5][0-9][0-5][0-9]/${TAG}/\" deployment.yaml\n#rm deployment.yaml-E\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Renaming in docker related files in the sample projects
426,496
23.06.2020 11:12:24
-7,200
4405a16c6659323adf39c1ae403a204cb082ca0a
Support for java 14 Fixes
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "language: java\ninstall: true\n-jdk: openjdk11\n+jdk:\n+ - openjdk11\n+ - openjdk14\nscript:\n- ./gradlew\n" }, { "change_type": "MODIFY", "old_path": "build.gradle", "new_path": "build.gradle", "diff": "@@ -3,6 +3,9 @@ import de.itemis.mps.gradle.RunAntScript\nimport de.itemis.mps.gradle.GenerateLibrariesXml\nimport de.itemis.mps.gradle.TestLanguages\n+\n+\n+\nbuildscript {\nrepositories {\nmaven { url 'https://projects.itemis.de/nexus/content/repositories/mbeddr' }\n@@ -35,9 +38,8 @@ if (ext.has('java11_home')) {\n} else if (System.getenv('JB_JAVA11_HOME') != null) {\njdk_home = System.getenv('JB_JAVA11_HOME')\n} else {\n- def expected = JavaVersion.VERSION_11\n- if (JavaVersion.current() != expected) {\n- throw new GradleException(\"This build script requires Java 11 but you are currently using ${JavaVersion.current()}.\\nWhat you can do:\\n\"\n+ if (!JavaVersion.current().isJava11Compatible()) {\n+ throw new GradleException(\"This build script requires Java >=11 but you are currently using ${JavaVersion.current()}.\\nWhat you can do:\\n\"\n+ \" * Use project property java11_home to point to the Java 11 JDK.\\n\"\n+ \" * Use environment variable JAVA11_HOME to point to the Java 11 JDK\\n\"\n+ \" * Run Gradle using Java 11\")\n" }, { "change_type": "MODIFY", "old_path": "gradle/wrapper/gradle-wrapper.jar", "new_path": "gradle/wrapper/gradle-wrapper.jar", "diff": "Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ\n" }, { "change_type": "MODIFY", "old_path": "gradle/wrapper/gradle-wrapper.properties", "new_path": "gradle/wrapper/gradle-wrapper.properties", "diff": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\n-distributionUrl=https\\://services.gradle.org/distributions/gradle-5.2.1-bin.zip\n+distributionUrl=https\\://services.gradle.org/distributions/gradle-6.5-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n" }, { "change_type": "MODIFY", "old_path": "gradlew", "new_path": "gradlew", "diff": "#!/usr/bin/env sh\n+#\n+# Copyright 2015 the original author or authors.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# https://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+\n##############################################################################\n##\n## Gradle start up script for UN*X\n@@ -28,7 +44,7 @@ APP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\n-DEFAULT_JVM_OPTS='\"-Xmx64m\"'\n+DEFAULT_JVM_OPTS='\"-Xmx64m\" \"-Xms64m\"'\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n@@ -109,8 +125,8 @@ if $darwin; then\nGRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n-# For Cygwin, switch paths to Windows format before running java\n-if $cygwin ; then\n+# For Cygwin or MSYS, switch paths to Windows format before running java\n+if [ \"$cygwin\" = \"true\" -o \"$msys\" = \"true\" ] ; then\nAPP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\nCLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\nJAVACMD=`cygpath --unix \"$JAVACMD\"`\n" }, { "change_type": "MODIFY", "old_path": "gradlew.bat", "new_path": "gradlew.bat", "diff": "+@rem\n+@rem Copyright 2015 the original author or authors.\n+@rem\n+@rem Licensed under the Apache License, Version 2.0 (the \"License\");\n+@rem you may not use this file except in compliance with the License.\n+@rem You may obtain a copy of the License at\n+@rem\n+@rem https://www.apache.org/licenses/LICENSE-2.0\n+@rem\n+@rem Unless required by applicable law or agreed to in writing, software\n+@rem distributed under the License is distributed on an \"AS IS\" BASIS,\n+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+@rem See the License for the specific language governing permissions and\n+@rem limitations under the License.\n+@rem\n+\n@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\n-set DEFAULT_JVM_OPTS=\"-Xmx64m\"\n+set DEFAULT_JVM_OPTS=\"-Xmx64m\" \"-Xms64m\"\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n" }, { "change_type": "MODIFY", "old_path": "ui-client/build.gradle", "new_path": "ui-client/build.gradle", "diff": "@@ -5,14 +5,13 @@ buildscript {\nurl 'https://plugins.gradle.org/m2/'\n}\n}\n-\n- dependencies {\n- classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0'\n}\n+\n+plugins {\n+ id \"com.github.node-gradle.node\" version \"2.2.4\"\n}\napply plugin: 'base'\n-apply plugin: 'com.moowork.node' // gradle-node-plugin\nnode {\n/* gradle-node-plugin configuration\n" }, { "change_type": "MODIFY", "old_path": "ui-server/build.gradle", "new_path": "ui-server/build.gradle", "diff": "@@ -17,9 +17,8 @@ if (ext.has('java11_home')) {\n} else if (System.getenv('JB_JAVA11_HOME') != null) {\njdk_home = System.getenv('JB_JAVA11_HOME')\n} else {\n- def expected = JavaVersion.VERSION_11\n- if (JavaVersion.current() != expected) {\n- throw new GradleException(\"This build script requires Java 11 but you are currently using ${JavaVersion.current()}.\\nWhat you can do:\\n\"\n+ if (!JavaVersion.current().isJava11Compatible()) {\n+ throw new GradleException(\"This build script requires Java >=11 but you are currently using ${JavaVersion.current()}.\\nWhat you can do:\\n\"\n+ \" * Use project property java11_home to point to the Java 11 JDK.\\n\"\n+ \" * Use environment variable JAVA11_HOME to point to the Java 11 JDK\\n\"\n+ \" * Run Gradle using Java 11\")\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Support for java 14 Fixes #8
426,496
30.06.2020 11:08:01
-7,200
63dc9119621f257c69f906ac31bc6ec4a04c2c85
Overview over the content of the root directory See
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -7,17 +7,9 @@ The modelix project develops a next generation language workbench that is native\n* Database/Cloud storage for MPS models with realtime collaboration\n* Server-based execution of MPS and browser-based editors\n-# Roadmap\n-\n-TBD.\n-\n-\n-# Clone the repo\n-\n-At this time there are no builds or releases available. You have to clone the repo to use modelix.\n-\n# How to run modelix\n+- At this time there are no builds or releases available. You have to clone the repo to use modelix.\n- You can run modelix locally and in the Google cloud. The details are described [on this wiki page](https://github.com/modelix/modelix/wiki/Running-Modelix).\n- Then check out some of the [samples](https://github.com/modelix/modelix/wiki/Samples).\n- Or check out the [tutorials](https://github.com/modelix/modelix/wiki/Tutorials).\n@@ -26,8 +18,53 @@ At this time there are no builds or releases available. You have to clone the re\n- run `gradlew` in the main directory to download dependencies and build the project\n- While the MPS that is used for the build is downloaded automatically, you have to install MPS yourself to use it as the client. Currently we rely on MPS 2020.1 which you can get from https://www.jetbrains.com/mps/\n-- open the project in the folder \"mps\" with MPS; you might want to rebuild it in the IDE\n-\n-\n+- open the project in the folder \"mps\" with MPS\n+\n+# Content of the root directory\n+\n+File | Description\n+---|---\n+[db](db) | Files for building the PostgreSQL docker image\n+[gradle-plugin](gradle-plugin) | files for building the PostgreSQL docker image\n+[gradle-plugin-test](gradle-plugin-test) | Demo project that uses the gradle plugin.\n+[kubernetes](kubernetes) | YAML configuration files for running modelix in a kubernetes cluster\n+[model-server](model-server) | Java project that implements a REST API on top of an [Apache Ignite](https://ignite.apache.org/) key value store. It is very generic and lightweight and doesn't know anything about models and their storage format. The mapping between the model data structure and the key value entries happens in MPS.\n+[mps](mps) | MPS project that implements all the MPS plugins. That's a plugin for synchronizing models with the model server and plugins for editing models in the browser.\n+[proxy](proxy) | Files for building a docker image for a reverse proxy used inside the kubernetes cluster.\n+[samples](samples) | Projects that show you how to build your own kubernetes cluster running MPS with custom languages.\n+[ssl](ssl) | SSL support inside the kubernetes cluster\n+[ui-client](ui-client) | A typescript project that implements the browser part of the editor. This is generic and doesn't contain anything language specific. All language specific parts are implements on the server side in MPS.\n+[ui-server](ui-server) | A small Java project that configures and starts MPS in headless mode.\n+[.dockerignore](.dockerignore) |\n+[.gitignore](.gitignore) |\n+[.travis.yml](.travis.yml) | Required for using travis as the CI server: <https://travis-ci.org/github/modelix/modelix>\n+[Dockerfile-mps](Dockerfile-mps) | The docker image for the UI server is split into a separate layer for MPS, because the MPS version changes less frequently and this speeds up the rebuild of the docker image.\n+[Dockerfile-ui](Dockerfile-ui) | For building the docker image of the UI server.\n+[LICENSE](LICENSE) |\n+[README.md](README.md) |\n+[build-scripts.xml](build-scripts.xml) | Generated by MPS for building the MPS project\n+[build.gradle](build.gradle) |\n+[docker-build-all.sh](docker-build-all.sh) | Builds all the docker images. You have to run `./gradlew` first.\n+[docker-build-db.sh](docker-build-db.sh) |\n+[docker-build-model.sh](docker-build-model.sh) |\n+[docker-build-mps.sh](docker-build-mps.sh) |\n+[docker-build-proxy.sh](docker-build-proxy.sh) |\n+[docker-build-ui.sh](docker-build-ui.sh) |\n+[docker-push-gcloud.sh](docker-push-gcloud.sh) |\n+[docker-push-hub.sh](docker-push-hub.sh) | Pushes all docker images to [hub.docker.com](https://hub.docker.com/u/modelix) and updates the version numbers in the kubernetes YAML files.\n+[docker-run-db.sh](docker-run-db.sh) | If you want to run the PostgresSQL database locally without a kubernetes cluster\n+[docker-run-model.sh](docker-run-model.sh) | If you want to run the model server docker image locally without a kubernetes cluster. You can also run `./gradlew run` in the [model-server](model-server) directory.\n+[docker-run-ui.sh](docker-run-ui.sh) | If you want to run the UI server docker image locally without a kubernetes cluster. You can also just open the [mps](mps) folder with [MPS](https://www.jetbrains.com/mps/) after running `./gradlew`.\n+[generate-modelsecret.sh](generate-modelsecret.sh) | Access to the model server requires clients to be logged in with their google account. Inside the kubernetes cluster the other components use a secret stored in the kubernetes cluster as the access token.\n+[gradlew](gradlew) | Run this to build all projects.\n+[gradlew.bat](gradlew.bat) | Run this to build all projects.\n+[kubernetes-apply-gcloud.sh](kubernetes-apply-gcloud.sh) |\n+[kubernetes-apply-local.sh](kubernetes-apply-local.sh) |\n+[kubernetes-gcloud-dbsecret.sh](kubernetes-gcloud-dbsecret.sh) |\n+[kubernetes-modelsecret.sh](kubernetes-modelsecret.sh) |\n+[run-ui-server.sh](run-ui-server.sh) | This is packaged into the docker image and doesn't work outside of it.\n+[settings.gradle](settings.gradle) |\n+[update-gcloud.sh](update-gcloud.sh) | If you want to build and run your own images inside you cluster.\n+[update-minikube.sh](update-minikube.sh) | If you want to build and run your own images inside you cluster.\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Overview over the content of the root directory See #7
426,496
30.06.2020 21:49:07
-7,200
2a7b490a630a99512c6f69e9e4d100a1ddf02d64
Started describing the architecture Some paragraphs about the UI server and the model data structure. See
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -20,6 +20,37 @@ The modelix project develops a next generation language workbench that is native\n- While the MPS that is used for the build is downloaded automatically, you have to install MPS yourself to use it as the client. Currently we rely on MPS 2020.1 which you can get from https://www.jetbrains.com/mps/\n- open the project in the folder \"mps\" with MPS\n+# Architecture\n+\n+modelix provides an editor in the browser for the languages implemented in MPS.\n+This can be an image based editor that renders the editor in MPS using the default editor definition\n+or an HTML based editor that requires a separate editor definition in a language provided by modelix.\n+\n+Common to both approaches is that the user input (keyboard, mouse) is processed on the server\n+and the update of the projection after a model change also happens on the server.\n+Even in case of the HTML based editor the resulting HTML is computed on the server side.\n+This removes the need to replicate the model into the browser, which would result in a bad performance in case of big models.\n+\n+Running MPS in the cloud requires an alternative to the file system for storing models.\n+modelix implements a data structure that allows replication between all MPS instances connected to the same model server.\n+It is very similar to the [git storage format](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects),\n+but instead of files it stores nodes in its key-value data store.\n+\n+To support realtime collaboration, in addition to the snapshot of a version it also stores the operations that were applied on the previous version to produce the new version.\n+Conflicts between concurrent modification are resolved using [operational transformation](https://en.wikipedia.org/wiki/Operational_transformation) (OT).\n+The usually hard part of OT is to guarantee convergence, meaning that all clients end up with the same result indepent of the order in which they receive changes.\n+This problem becomes trivial, because versions are identified by a hash over all the content.\n+Any divergence will result in a different hash which can easily be detected.\n+\n+The remaining problem is what to do when a divergence is detected.\n+From git we know that switching between versions is fast, because it only has to apply the difference between these versions.\n+The same is true here.\n+Fixing a divergence is as easy as switching to the correct version.\n+If a client doesn't have any local changes it doesn't even need to apply the change operations itself.\n+It can just switch to the new version.\n+So in the rare case of a divergence fixing it is nothing special.\n+It's an operation that happens all the time.\n+\n# Content of the root directory\nFile | Description\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Started describing the architecture Some paragraphs about the UI server and the model data structure. See #7
426,496
02.07.2020 14:50:23
-7,200
ace71f4eec0afc2754f65784fa4aac5fd4dd201a
A git repository containing MPS models can be passed to the UI server The repository is cloned and the models are loaded in MPS.
[ { "change_type": "MODIFY", "old_path": "Dockerfile-ui", "new_path": "Dockerfile-ui", "diff": "@@ -16,4 +16,5 @@ RUN ls /usr/modelix-ui/mps/plugins/\nCOPY run-ui-server.sh /usr/modelix-ui\nCOPY ui-server/build/libs/ui-server-1.0-SNAPSHOT.jar /usr/modelix-ui/ui-server.jar\n+COPY ui-server/build/dependencies/ /usr/modelix-ui/dependencies/\nCMD [\"./run-ui-server.sh\"]\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "new_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "diff": "<node concept=\"027rt\" id=\"7fn21XE1rh_\" role=\"8Wnug\">\n<ref role=\"027rv\" to=\"70w2:7NImM053Sep\" resolve=\"children\" />\n<node concept=\"214gnc\" id=\"7fn21XE1sbF\" role=\"027rp\">\n- <ref role=\"1YEVMl\" node=\"7trMQm3W2UH\" resolve=\"svgNodeEditor\" />\n+ <ref role=\"1YEVMl\" node=\"7trMQm3W2UH\" resolve=\"imageNodeEditor\" />\n<node concept=\"214o7A\" id=\"7fn21XE1sbQ\" role=\"214sll\" />\n</node>\n</node>\n<node concept=\"027rt\" id=\"62_qJBxNm_g\" role=\"02LM9\">\n<ref role=\"027rv\" to=\"70w2:7NImM053Sep\" resolve=\"children\" />\n<node concept=\"214gnc\" id=\"7trMQm3aFic\" role=\"027rp\">\n- <ref role=\"1YEVMl\" node=\"7trMQm3aARC\" resolve=\"nodeEditor\" />\n+ <ref role=\"1YEVMl\" node=\"7trMQm3W2UH\" resolve=\"imageNodeEditor\" />\n<node concept=\"214o7A\" id=\"7trMQm3aFiA\" role=\"214sll\" />\n</node>\n</node>\n</node>\n<node concept=\"2OrE70\" id=\"7vWAzuELdpZ\" role=\"02uzr\" />\n<node concept=\"02vpq\" id=\"7trMQm3aARC\" role=\"02uzr\">\n- <property role=\"TrG5h\" value=\"nodeEditor\" />\n+ <property role=\"TrG5h\" value=\"htmlNodeEditor\" />\n<node concept=\"02i3K\" id=\"7trMQm3aC3$\" role=\"02i3f\">\n<property role=\"TrG5h\" value=\"node\" />\n<node concept=\"02i3D\" id=\"7trMQm3aCa4\" role=\"02i2B\">\n</node>\n<node concept=\"2OrE70\" id=\"7trMQm3W4dc\" role=\"02uzr\" />\n<node concept=\"02vpq\" id=\"7trMQm3W2UH\" role=\"02uzr\">\n- <property role=\"TrG5h\" value=\"svgNodeEditor\" />\n+ <property role=\"TrG5h\" value=\"imageNodeEditor\" />\n<node concept=\"02i3K\" id=\"7trMQm3W2UI\" role=\"02i3f\">\n<property role=\"TrG5h\" value=\"node\" />\n<node concept=\"02i3D\" id=\"7trMQm3W2UJ\" role=\"02i2B\">\n<node concept=\"027rt\" id=\"4JrW6Yv4WS8\" role=\"02LM9\">\n<ref role=\"027rv\" to=\"70w2:7NImM053Sep\" resolve=\"children\" />\n<node concept=\"214gnc\" id=\"4JrW6Yv4XEm\" role=\"027rp\">\n- <ref role=\"1YEVMl\" node=\"7trMQm3aARC\" resolve=\"nodeEditor\" />\n+ <ref role=\"1YEVMl\" node=\"7trMQm3aARC\" resolve=\"htmlNodeEditor\" />\n<node concept=\"214o7A\" id=\"4JrW6Yv4XKn\" role=\"214sll\" />\n</node>\n</node>\n<node concept=\"027rt\" id=\"7trMQm3mukV\" role=\"02LM9\">\n<ref role=\"027rv\" to=\"70w2:7NImM053Sep\" resolve=\"children\" />\n<node concept=\"214gnc\" id=\"7trMQm3muDH\" role=\"027rp\">\n- <ref role=\"1YEVMl\" node=\"7trMQm3W2UH\" resolve=\"svgNodeEditor\" />\n+ <ref role=\"1YEVMl\" node=\"7trMQm3W2UH\" resolve=\"imageNodeEditor\" />\n<node concept=\"214o7A\" id=\"7trMQm3muDO\" role=\"214sll\" />\n</node>\n</node>\n" }, { "change_type": "MODIFY", "old_path": "run-ui-server.sh", "new_path": "run-ui-server.sh", "diff": "#!/bin/sh\njava -DMODEL_URI=$MODEL_URI \\\n+ -DGIT_REPO_URI=$GIT_REPO_URI \\\n-DTREE_ID=$TREE_ID \\\n- -classpath \"./ui-server.jar:./mps/lib/*\" \\\n+ -classpath \"./ui-server.jar:./mps/lib/*:./dependencies/*\" \\\n-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5071 \\\norg.modelix.ui.server.Main\n" }, { "change_type": "MODIFY", "old_path": "ui-server/build.gradle", "new_path": "ui-server/build.gradle", "diff": "@@ -8,60 +8,19 @@ description = \"modelix UI server\"\nsourceCompatibility = 1.11\ntargetCompatibility = 1.11\n-\n-\n-def jdk_home\n-\n-if (ext.has('java11_home')) {\n- jdk_home = ext.get('java11_home')\n-} else if (System.getenv('JB_JAVA11_HOME') != null) {\n- jdk_home = System.getenv('JB_JAVA11_HOME')\n-} else {\n- if (!JavaVersion.current().isJava11Compatible()) {\n- throw new GradleException(\"This build script requires Java >=11 but you are currently using ${JavaVersion.current()}.\\nWhat you can do:\\n\"\n- + \" * Use project property java11_home to point to the Java 11 JDK.\\n\"\n- + \" * Use environment variable JAVA11_HOME to point to the Java 11 JDK\\n\"\n- + \" * Run Gradle using Java 11\")\n- }\n- jdk_home = System.getProperty('java.home')\n-}\n-\n-// Check JDK location\n-if (!new File(jdk_home, \"lib\").exists()) {\n- throw new GradleException(\"Unable to locate JDK home folder. Detected folder is: $jdk_home\")\n-}\n-\n-// https://docs.gradle.org/current/userguide/building_java_projects.html#example_configure_java_7_build\n-def javaExecutablesPath = new File(jdk_home, 'bin')\n-def javaExecutables = [:].withDefault { execName ->\n- def executable = new File(javaExecutablesPath, execName)\n- assert executable.exists(): \"There is no ${execName} executable in ${javaExecutablesPath}\"\n- executable\n-}\n-tasks.withType(AbstractCompile) {\n- options.with {\n- fork = true\n- forkOptions.javaHome = file(jdk_home)\n- }\n-}\n-tasks.withType(Javadoc) {\n- executable = javaExecutables.javadoc\n-}\n-tasks.withType(Test) {\n- executable = javaExecutables.java\n-}\n-tasks.withType(JavaExec) {\n- executable = javaExecutables.java\n-}\n-\n-\n-\n-\nrepositories {\n-\nmaven { url \"https://repo.maven.apache.org/maven2\" }\n}\ndependencies {\n- compile fileTree(dir: '../artifacts/mps/lib', include: '*.jar')\n+ compileOnly fileTree(dir: '../artifacts/mps/lib', include: '*.jar')\n+ compile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.8.0.202006091008-r'\n+ compile group: 'commons-io', name: 'commons-io', version: '2.7'\n}\n+\n+task copyRuntimeLibs(type: Copy) {\n+ into \"$buildDir/dependencies\"\n+ from configurations.runtime\n+}\n+\n+assemble.dependsOn copyRuntimeLibs\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "ui-server/src/main/java/org/modelix/ui/server/EnvironmentLoader.java", "new_path": "ui-server/src/main/java/org/modelix/ui/server/EnvironmentLoader.java", "diff": "@@ -23,7 +23,7 @@ public class EnvironmentLoader {\nourProject = project;\n}\n- public static Project loadEnvironment() {\n+ public static Project loadEnvironment(File gitRepoDir) {\nif (ourProject == null) {\n// If you get the exception \"Could not find installation home path\"\n// Set \"-Didea.home\" in the VM options\n@@ -50,6 +50,9 @@ public class EnvironmentLoader {\n.addPlugin(\"org.modelix.model\", \"org.modelix.model\")\n.addPlugin(\"org.modelix.common\", \"org.modelix.common\")\n;\n+ if (gitRepoDir != null) {\n+ config.addLib(gitRepoDir.getAbsolutePath());\n+ }\n// for (IdeaPluginDescriptorImpl plugin : PluginManagerCore.loadDescriptors(null, new ArrayList<String>())) {\n// System.out.println(\"addPlugin(\" + plugin.getPath() + \", \" + plugin.getPluginId().getIdString() + \")\");\n" }, { "change_type": "MODIFY", "old_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "new_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "diff": "package org.modelix.ui.server;\n+import com.google.common.io.Files;\n+import org.apache.commons.io.FileUtils;\nimport org.apache.log4j.Logger;\n+import org.eclipse.jgit.api.Git;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.util.HashSet;\n+import java.util.Set;\npublic class Main {\nprivate static final Logger LOG = Logger.getLogger(Main.class);\n- public static void main(String[] args) {\n+ public static void main(String[] args) throws Exception {\n+ try {\n+ File gitRepoDir = null;\n+\n+ String gitRepoUri = System.getProperty(\"GIT_REPO_URI\");\n+ if (gitRepoUri == null || gitRepoUri.length() == 0) gitRepoUri = System.getenv(\"GIT_REPO_URI\");\n+\n+ if (gitRepoUri != null && gitRepoUri.length() > 0) {\n+ System.out.println(\"Cloning \" + gitRepoUri);\n+\n+ gitRepoDir = Files.createTempDir();\n+ recursiveDeleteOnExit(gitRepoDir);\n+ Git git = Git.cloneRepository()\n+ .setURI(gitRepoUri)\n+ .setDirectory(gitRepoDir)\n+ .call();\n+ Set<File> files = new HashSet<>();\n+ System.out.println(\"Searching in \" + gitRepoDir);\n+ collectMPSFiles(gitRepoDir, files);\n+ files.forEach(f -> System.out.println(\"MPS related file found: \" + f));\n+ }\n+\nLOG.error(\"Test error\");\nLOG.warn(\"Test warning\");\nLOG.info(\"Test info\");\nLOG.debug(\"Test debug\");\nLOG.trace(\"Test trace\");\n- EnvironmentLoader.loadEnvironment();\n+ EnvironmentLoader.loadEnvironment(gitRepoDir);\nLOG.debug(\"idea.load.plugins.id: \" + System.getProperty(\"idea.load.plugins.id\"));\n+ } catch (Exception ex) {\n+ LOG.error(ex);\n+ }\n+ }\n+\n+ private static void collectMPSFiles(File file, Set<File> acc) {\n+ String name = file.getName().toLowerCase();\n+ if (name.endsWith(\".mps\") || name.endsWith(\".mpl\") || name.endsWith(\".msd\") || name.endsWith(\".devkit\")) {\n+ acc.add(file);\n+ }\n+\n+ if (file.isDirectory()) {\n+ for (File subfile : file.listFiles()) {\n+ collectMPSFiles(subfile, acc);\n+ }\n+ }\n+ }\n+\n+ public static void recursiveDeleteOnExit(final File dir) {\n+ Runtime.getRuntime().addShutdownHook(new Thread() {\n+ @Override\n+ public void run() {\n+ try {\n+ FileUtils.deleteDirectory(dir);\n+ } catch (IOException e) {\n+ LOG.error(e);\n+ }\n+ }\n+ });\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
A git repository containing MPS models can be passed to the UI server The repository is cloned and the models are loaded in MPS.
426,496
03.07.2020 20:10:54
-7,200
9558980e821a0da4473407eb629256ca4c0b9763
Proxy for websocket connections
[ { "change_type": "ADD", "old_path": null, "new_path": "kubernetes/common/role-binding.yaml", "diff": "+kind: ClusterRoleBinding\n+apiVersion: rbac.authorization.k8s.io/v1\n+metadata:\n+ name: editing-for-all\n+ namespace: default\n+subjects:\n+- kind: ServiceAccount\n+ name: default\n+ namespace: default\n+roleRef:\n+ kind: ClusterRole\n+ name: edit\n+ apiGroup: rbac.authorization.k8s.io\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "kubernetes/common/uiproxy-deployment.yaml", "diff": "+apiVersion: apps/v1\n+kind: Deployment\n+metadata:\n+ labels:\n+ app: uiproxy\n+ name: uiproxy\n+spec:\n+ revisionHistoryLimit: 5\n+ replicas: 1\n+ strategy:\n+ type: RollingUpdate\n+ rollingUpdate:\n+ maxUnavailable: 1\n+ maxSurge: 0\n+ selector:\n+ matchLabels:\n+ app: uiproxy\n+ template:\n+ metadata:\n+ creationTimestamp: null\n+ labels:\n+ app: uiproxy\n+ spec:\n+ containers:\n+ - image: modelix/modelix-uiproxy:latest\n+ imagePullPolicy: IfNotPresent\n+ name: uiproxy\n+ ports:\n+ - containerPort: 33332\n+ resources:\n+ requests:\n+ memory: \"100Mi\"\n+ cpu: \"0.1\"\n+ limits:\n+ memory: \"200Mi\"\n+ cpu: \"1.0\"\n+ restartPolicy: Always\n" }, { "change_type": "ADD", "old_path": null, "new_path": "kubernetes/common/uiproxy-service.yaml", "diff": "+apiVersion: v1\n+kind: Service\n+metadata:\n+ labels:\n+ app: uiproxy\n+ name: uiproxy\n+spec:\n+ type: NodePort\n+ ports:\n+ - name: \"33332\"\n+ port: 33332\n+ targetPort: 33332\n+ selector:\n+ app: uiproxy\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "new_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "diff": "<ref role=\"02i3$\" to=\"tpce:h0PkWnZ\" resolve=\"AbstractConceptDeclaration\" />\n</node>\n</node>\n+ <node concept=\"3clFbT\" id=\"6pXrrBnrKJB\" role=\"vpezr\" />\n</node>\n<node concept=\"2OrE70\" id=\"7trMQm2QQnv\" role=\"02uzr\" />\n<node concept=\"02vpq\" id=\"7trMQm3l_jO\" role=\"02uzr\">\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/build.gradle", "new_path": "ui-proxy/build.gradle", "diff": "@@ -26,6 +26,10 @@ dependencies {\ncompile group: 'org.eclipse.jetty', name: 'jetty-server', version: jettyVersion\ncompile group: 'org.eclipse.jetty', name: 'jetty-proxy', version: jettyVersion\ncompile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: jettyVersion\n+ compile group: 'org.eclipse.jetty.websocket', name: 'websocket-servlet', version: jettyVersion\n+ compile group: 'org.eclipse.jetty.websocket', name: 'websocket-client', version: jettyVersion\n+ compile group: 'org.eclipse.jetty.websocket', name: 'websocket-server', version: jettyVersion\n+\ncompile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.8.0.202006091008-r'\n}\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "diff": "@@ -5,28 +5,44 @@ import io.kubernetes.client.openapi.ApiException;\nimport io.kubernetes.client.openapi.Configuration;\nimport io.kubernetes.client.openapi.apis.AppsV1Api;\nimport io.kubernetes.client.openapi.apis.CoreV1Api;\n-import io.kubernetes.client.openapi.models.*;\n+import io.kubernetes.client.openapi.models.V1Deployment;\n+import io.kubernetes.client.openapi.models.V1DeploymentBuilder;\n+import io.kubernetes.client.openapi.models.V1DeploymentList;\n+import io.kubernetes.client.openapi.models.V1Service;\n+import io.kubernetes.client.openapi.models.V1ServiceBuilder;\n+import io.kubernetes.client.openapi.models.V1ServiceList;\nimport io.kubernetes.client.util.ClientBuilder;\nimport io.kubernetes.client.util.Yaml;\nimport org.apache.commons.codec.digest.DigestUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jetty.proxy.ProxyServlet;\n+import org.eclipse.jetty.server.Request;\nimport org.eclipse.jetty.server.Server;\n+import org.eclipse.jetty.server.handler.DefaultHandler;\n+import org.eclipse.jetty.server.handler.HandlerList;\n+import org.eclipse.jetty.server.handler.HandlerWrapper;\nimport org.eclipse.jetty.servlet.ServletContextHandler;\n+import org.eclipse.jetty.servlet.ServletHandler;\nimport org.eclipse.jetty.servlet.ServletHolder;\n+import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;\n+import org.eclipse.jetty.websocket.servlet.WebSocketServlet;\nimport org.eclipse.jgit.api.Git;\nimport org.eclipse.jgit.api.errors.GitAPIException;\nimport org.eclipse.jgit.lib.Ref;\n+import javax.servlet.ServletException;\nimport javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\nimport java.io.IOException;\n+import java.net.URI;\n+import java.net.URISyntaxException;\nimport java.util.Arrays;\nimport java.util.Collection;\n-import java.util.Random;\nimport java.util.function.Supplier;\npublic class Main {\nprivate static final Logger LOG = Logger.getLogger(Main.class);\n+ private static final String DEPLOYMENT_PREFIX = \"ui-git-\";\npublic static void main(String[] args) {\ntry {\n@@ -35,7 +51,7 @@ public class Main {\nSystem.out.println(\"code: \" + ex.getCode());\nSystem.out.println(\"body: \" + ex.getResponseBody());\n} catch (Exception ex) {\n- LOG.error(ex);\n+ LOG.error(\"\", ex);\nex.printStackTrace();\nThrowable cause = ex.getCause();\nif (cause != null) {\n@@ -47,6 +63,38 @@ public class Main {\nprivate static void startServer() throws Exception {\nServer server = new Server(33332);\n+ HandlerList handlerList = new HandlerList();\n+ server.setHandler(handlerList);\n+\n+\n+ WebSocketServlet webSocketServlet = new WebSocketProxyServlet() {\n+ @Override\n+ protected URI redirect(ServletUpgradeRequest request) {\n+ String path = request.getRequestURI().getPath();\n+ String[] repoUrlAndRemainingPath = repoUrlFromRequest(path);\n+ String repoUrl = repoUrlAndRemainingPath[0];\n+ String remainingPath = repoUrlAndRemainingPath[1];\n+ String deploymentName = repoUrlTodeploymentName(repoUrl);\n+ try {\n+ return new URI(targetUrl(deploymentName, remainingPath, true));\n+ } catch (URISyntaxException e) {\n+ throw new RuntimeException(e);\n+ }\n+ }\n+ };\n+ HandlerWrapper webSocketHandlerCondition = new HandlerWrapper() {\n+ @Override\n+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n+ if (!baseRequest.getRequestURI().contains(\"/ws/\")) return;\n+ super.handle(target, baseRequest, request, response);\n+ }\n+ };\n+ ServletContextHandler webSocketHandler = new ServletContextHandler();\n+ webSocketHandler.addServlet(new ServletHolder(webSocketServlet), \"/*\");\n+ webSocketHandlerCondition.setHandler(webSocketHandler);\n+ handlerList.addHandler(webSocketHandlerCondition);\n+\n+\nProxyServlet proxyServlet = new ProxyServlet() {\n@Override\nprotected String rewriteTarget(HttpServletRequest clientRequest) {\n@@ -67,7 +115,7 @@ public class Main {\n.setHeads(true)\n.call();\n} catch (GitAPIException e) {\n- LOG.error(e);\n+ LOG.error(\"\", e);\nreturn false;\n}\nfor (Ref ref : refs) {\n@@ -81,7 +129,7 @@ public class Main {\n});\nif (deploymentName == null) return null;\n- String newTarget = \"http://\" + deploymentName + \":33333\" + remainingPath;\n+ String newTarget = targetUrl(deploymentName, remainingPath, false);\nif (clientRequest.getQueryString() != null && clientRequest.getQueryString().length() != 0) {\nnewTarget += \"?\" + clientRequest.getQueryString();\n}\n@@ -93,9 +141,12 @@ public class Main {\n}\n};\n- ServletContextHandler servletHandler = new ServletContextHandler();\n- servletHandler.addServlet(new ServletHolder(proxyServlet), \"/*\");\n- server.setHandler(servletHandler);\n+\n+ ServletContextHandler proxyHandler = new ServletContextHandler();\n+ proxyHandler.addServlet(new ServletHolder(proxyServlet), \"/*\");\n+ handlerList.addHandler(proxyHandler);\n+\n+ handlerList.addHandler(new DefaultHandler());\nserver.start();\nRuntime.getRuntime().addShutdownHook(new Thread() {\n@@ -111,18 +162,25 @@ public class Main {\n});\n}\n+ private static String repoUrlTodeploymentName(String repoUrl) {\n+ return DEPLOYMENT_PREFIX + DigestUtils.sha1Hex(repoUrl);\n+ }\n+\n+ private static String targetUrl(String deploymentName, String remainingPath, boolean websocket) {\n+ return (websocket ? \"ws\" : \"http\") + \"://\" + deploymentName + \":33333\" + remainingPath;\n+ }\n+\nprivate static String createDeployment(String gitRepoUrl, Supplier<Boolean> urlValidator) throws IOException, ApiException {\nConfiguration.setDefaultApiClient(ClientBuilder.cluster().build());\n- String namePrefix = \"ui-git-\";\n- String name = namePrefix + DigestUtils.sha1Hex(gitRepoUrl);\n+ String name = repoUrlTodeploymentName(gitRepoUrl);\nAppsV1Api appsApi = new AppsV1Api();\nV1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, 5, false);\nboolean deploymentExists = deployments.getItems().stream().anyMatch(d -> name.equals(d.getMetadata().getName()));\nif (!deploymentExists) {\n- long numExisting = deployments.getItems().stream().filter(d -> d.getMetadata().getName().startsWith(namePrefix)).count();\n+ long numExisting = deployments.getItems().stream().filter(d -> d.getMetadata().getName().startsWith(DEPLOYMENT_PREFIX)).count();\nif (numExisting > 10) throw new RuntimeException(\"Too many existing deployments\");\nif (!urlValidator.get()) {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/WebSocketProxyServlet.java", "diff": "+package org.modelix.uiproxy;\n+\n+import org.apache.log4j.Logger;\n+import org.eclipse.jetty.websocket.api.Session;\n+import org.eclipse.jetty.websocket.api.WebSocketAdapter;\n+import org.eclipse.jetty.websocket.api.WebSocketConnectionListener;\n+import org.eclipse.jetty.websocket.api.WebSocketListener;\n+import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;\n+import org.eclipse.jetty.websocket.client.WebSocketClient;\n+import org.eclipse.jetty.websocket.servlet.*;\n+\n+import java.io.IOException;\n+import java.net.URI;\n+import java.net.URISyntaxException;\n+import java.nio.ByteBuffer;\n+import java.util.concurrent.Future;\n+\n+public abstract class WebSocketProxyServlet extends WebSocketServlet {\n+ private static final Logger LOG = Logger.getLogger(WebSocketProxyServlet.class);\n+\n+ protected abstract URI redirect(ServletUpgradeRequest request);\n+\n+ @Override\n+ public void configure(WebSocketServletFactory factory) {\n+ factory.getPolicy().setMaxTextMessageSize(20 * 1024 * 1024);\n+ factory.setCreator(new WebSocketCreator() {\n+ @Override\n+ public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {\n+\n+ return new WebSocketListener() {\n+ private WebSocketClient client = new WebSocketClient();\n+ private Session sessionA;\n+ private Session sessionB;\n+\n+ @Override\n+ public void onWebSocketConnect(final Session session) {\n+ sessionA = session;\n+ try {\n+ client.start();\n+ client.getPolicy().setMaxTextMessageSize(20 * 1024 * 1024);\n+ client.connect(new WebSocketListener() {\n+ @Override\n+ public void onWebSocketBinary(byte[] payload, int offset, int len) {\n+\n+ }\n+\n+ @Override\n+ public void onWebSocketText(String message) {\n+ try {\n+ sessionA.getRemote().sendString(message);\n+ } catch (IOException e) {\n+ throw new RuntimeException(e);\n+ }\n+ }\n+\n+ @Override\n+ public void onWebSocketClose(int statusCode, String reason) {\n+ sessionA.close(statusCode, reason);\n+ }\n+\n+ @Override\n+ public void onWebSocketConnect(Session session) {\n+ sessionB = session;\n+ }\n+\n+ @Override\n+ public void onWebSocketError(Throwable cause) {\n+ LOG.error(\"\", cause);\n+ }\n+ }, redirect(req), new ClientUpgradeRequest()).get();\n+ } catch (Exception e) {\n+ throw new RuntimeException(e);\n+ }\n+ }\n+\n+ @Override\n+ public void onWebSocketText(String message) {\n+ try {\n+ sessionB.getRemote().sendString(message);\n+ } catch (IOException e) {\n+ throw new RuntimeException(e);\n+ }\n+ }\n+\n+ @Override\n+ public void onWebSocketBinary(byte[] payload, int offset, int len) {\n+ try {\n+ sessionB.getRemote().sendBytes(ByteBuffer.wrap(payload, offset, len));\n+ } catch (IOException e) {\n+ throw new RuntimeException(e);\n+ }\n+ }\n+\n+ @Override\n+ public void onWebSocketClose(int statusCode, String reason) {\n+ sessionB.close(statusCode, reason);\n+ try {\n+ client.stop();\n+ } catch (Exception e) {\n+ LOG.error(\"\", e);\n+ }\n+ }\n+\n+ @Override\n+ public void onWebSocketError(Throwable cause) {\n+ LOG.error(\"\", cause);\n+ }\n+ };\n+ }\n+ });\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Proxy for websocket connections
426,496
03.07.2020 23:44:41
-7,200
ef8e3436812612a17b710be31c8d4bfa8b319390
Show placeholder page while the MPS instance is started
[ { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "diff": "@@ -16,8 +16,10 @@ import io.kubernetes.client.util.Yaml;\nimport org.apache.commons.codec.digest.DigestUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jetty.proxy.ProxyServlet;\n+import org.eclipse.jetty.server.Handler;\nimport org.eclipse.jetty.server.Request;\nimport org.eclipse.jetty.server.Server;\n+import org.eclipse.jetty.server.handler.AbstractHandler;\nimport org.eclipse.jetty.server.handler.DefaultHandler;\nimport org.eclipse.jetty.server.handler.HandlerList;\nimport org.eclipse.jetty.server.handler.HandlerWrapper;\n@@ -42,7 +44,7 @@ import java.util.function.Supplier;\npublic class Main {\nprivate static final Logger LOG = Logger.getLogger(Main.class);\n- private static final String DEPLOYMENT_PREFIX = \"ui-git-\";\n+\npublic static void main(String[] args) {\ntry {\n@@ -66,51 +68,19 @@ public class Main {\nHandlerList handlerList = new HandlerList();\nserver.setHandler(handlerList);\n-\n- WebSocketServlet webSocketServlet = new WebSocketProxyServlet() {\n- @Override\n- protected URI redirect(ServletUpgradeRequest request) {\n- String path = request.getRequestURI().getPath();\n- String[] repoUrlAndRemainingPath = repoUrlFromRequest(path);\n- String repoUrl = repoUrlAndRemainingPath[0];\n- String remainingPath = repoUrlAndRemainingPath[1];\n- String deploymentName = repoUrlTodeploymentName(repoUrl);\n- try {\n- return new URI(targetUrl(deploymentName, remainingPath, true));\n- } catch (URISyntaxException e) {\n- throw new RuntimeException(e);\n- }\n- }\n- };\n- HandlerWrapper webSocketHandlerCondition = new HandlerWrapper() {\n+ Handler deploymentManagingHandler = new AbstractHandler() {\n@Override\npublic void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n- if (!baseRequest.getRequestURI().contains(\"/ws/\")) return;\n- super.handle(target, baseRequest, request, response);\n- }\n- };\n- ServletContextHandler webSocketHandler = new ServletContextHandler();\n- webSocketHandler.addServlet(new ServletHolder(webSocketServlet), \"/*\");\n- webSocketHandlerCondition.setHandler(webSocketHandler);\n- handlerList.addHandler(webSocketHandlerCondition);\n-\n-\n- ProxyServlet proxyServlet = new ProxyServlet() {\n- @Override\n- protected String rewriteTarget(HttpServletRequest clientRequest) {\n- System.out.println(\"requestURI: \" + clientRequest.getRequestURI());\n- String[] repoUrlAndRemainingPath = repoUrlFromRequest(clientRequest.getRequestURI());\n- if (repoUrlAndRemainingPath == null) return null;\n- String repoUrl = repoUrlAndRemainingPath[0];\n- String remainingPath = repoUrlAndRemainingPath[1];\n- String deploymentName;\n- System.out.println(\"repo URL: \" + repoUrl);\ntry {\n- deploymentName = createDeployment(repoUrl, () -> {\n+ System.out.println(\"requestURI: \" + request.getRequestURI());\n+ RedirectedURL redirectedURL = RedirectedURL.redirect(request);\n+ if (redirectedURL == null) throw new RuntimeException(\"Invalid request: \" + request.getRequestURI());\n+ System.out.println(\"repo URL: \" + redirectedURL.getRepositoryUrl());\n+ boolean deploymentCreated = createDeployment(redirectedURL, () -> {\nCollection<Ref> refs = null;\ntry {\nrefs = Git.lsRemoteRepository()\n- .setRemote(repoUrl)\n+ .setRemote(redirectedURL.getRepositoryUrl())\n.setTags(false)\n.setHeads(true)\n.call();\n@@ -127,18 +97,63 @@ public class Main {\n}\nreturn false;\n});\n- if (deploymentName == null) return null;\n+ if (!deploymentCreated) throw new RuntimeException(\"Not git repository found at \" + redirectedURL.getRepositoryUrl());\n- String newTarget = targetUrl(deploymentName, remainingPath, false);\n- if (clientRequest.getQueryString() != null && clientRequest.getQueryString().length() != 0) {\n- newTarget += \"?\" + clientRequest.getQueryString();\n+ V1Deployment deployment = getDeployment(redirectedURL.getDeploymentName());\n+ if (deployment == null) throw new RuntimeException(\"Failed to create deployment\");\n+\n+ Integer readyReplicas = deployment.getStatus() != null ? deployment.getStatus().getReadyReplicas() : null;\n+ if (readyReplicas == null || readyReplicas == 0) {\n+ baseRequest.setHandled(true);\n+ response.setContentType(\"text/html\");\n+ response.setStatus(HttpServletResponse.SC_OK);\n+ response.getWriter()\n+ .append(\"<html>\")\n+ .append(\"<head>\")\n+ .append(\"<meta http-equiv=\\\"refresh\\\" content=\\\"5\\\">\")\n+ .append(\"</head>\")\n+ .append(\"<body>\")\n+ .append(\"Starting MPS and loading \" + redirectedURL.getRepositoryUrl() + \" ...\")\n+ .append(\"</body>\")\n+ .append(\"</html>\");\n}\n- System.out.println(\"Redirecting to \" + newTarget);\n- return newTarget;\n} catch (Exception ex) {\nthrow new RuntimeException(ex);\n}\n+ }\n+ };\n+ handlerList.addHandler(deploymentManagingHandler);\n+\n+ WebSocketServlet webSocketServlet = new WebSocketProxyServlet() {\n+ @Override\n+ protected URI redirect(ServletUpgradeRequest request) {\n+ String path = request.getRequestURI().getPath();\n+ RedirectedURL redirectedURL = RedirectedURL.redirect(request.getHttpServletRequest());\n+ try {\n+ return new URI(redirectedURL.getRedirectedUrl(true));\n+ } catch (URISyntaxException e) {\n+ throw new RuntimeException(e);\n+ }\n+ }\n+ };\n+ HandlerWrapper webSocketHandlerCondition = new HandlerWrapper() {\n+ @Override\n+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n+ if (!baseRequest.getRequestURI().contains(\"/ws/\")) return;\n+ super.handle(target, baseRequest, request, response);\n+ }\n+ };\n+ ServletContextHandler webSocketHandler = new ServletContextHandler();\n+ webSocketHandler.addServlet(new ServletHolder(webSocketServlet), \"/*\");\n+ webSocketHandlerCondition.setHandler(webSocketHandler);\n+ handlerList.addHandler(webSocketHandlerCondition);\n+\n+ ProxyServlet proxyServlet = new ProxyServlet() {\n+ @Override\n+ protected String rewriteTarget(HttpServletRequest clientRequest) {\n+ RedirectedURL redirectedURL = RedirectedURL.redirect(clientRequest);\n+ return redirectedURL.getRedirectedUrl(false);\n}\n};\n@@ -162,29 +177,36 @@ public class Main {\n});\n}\n- private static String repoUrlTodeploymentName(String repoUrl) {\n- return DEPLOYMENT_PREFIX + DigestUtils.sha1Hex(repoUrl);\n+ private static boolean isDeploymentReady(String name) throws ApiException {\n+ V1Deployment deployment = getDeployment(name);\n+ if (deployment == null) return false;\n+ return deployment.getStatus().getReadyReplicas() > 0;\n}\n- private static String targetUrl(String deploymentName, String remainingPath, boolean websocket) {\n- return (websocket ? \"ws\" : \"http\") + \"://\" + deploymentName + \":33333\" + remainingPath;\n+ private static V1Deployment getDeployment(String name) throws ApiException {\n+ AppsV1Api appsApi = new AppsV1Api();\n+ V1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, null, null);\n+ for (V1Deployment deployment : deployments.getItems()) {\n+ if (name.equals(deployment.getMetadata().getName())) return deployment;\n+ }\n+ return null;\n}\n- private static String createDeployment(String gitRepoUrl, Supplier<Boolean> urlValidator) throws IOException, ApiException {\n+ private static boolean createDeployment(RedirectedURL gitRepoUrl, Supplier<Boolean> urlValidator) throws IOException, ApiException {\nConfiguration.setDefaultApiClient(ClientBuilder.cluster().build());\n- String name = repoUrlTodeploymentName(gitRepoUrl);\n+ String name = gitRepoUrl.getDeploymentName();\nAppsV1Api appsApi = new AppsV1Api();\nV1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, 5, false);\nboolean deploymentExists = deployments.getItems().stream().anyMatch(d -> name.equals(d.getMetadata().getName()));\nif (!deploymentExists) {\n- long numExisting = deployments.getItems().stream().filter(d -> d.getMetadata().getName().startsWith(DEPLOYMENT_PREFIX)).count();\n+ long numExisting = deployments.getItems().stream().filter(d -> d.getMetadata().getName().startsWith(RedirectedURL.DEPLOYMENT_PREFIX)).count();\nif (numExisting > 10) throw new RuntimeException(\"Too many existing deployments\");\nif (!urlValidator.get()) {\n- return null;\n+ return false;\n}\nV1Deployment deployment = new V1DeploymentBuilder()\n@@ -207,7 +229,7 @@ public class Main {\n.withImagePullPolicy(\"IfNotPresent\")\n.addNewEnv()\n.withName(\"GIT_REPO_URI\")\n- .withValue(gitRepoUrl)\n+ .withValue(gitRepoUrl.getRepositoryUrl())\n.endEnv()\n.addNewPort()\n.withContainerPort(33333)\n@@ -283,20 +305,6 @@ public class Main {\ncoreApi.createNamespacedService(\"default\", service, null, null, null);\n}\n- return name;\n- }\n-\n- private static String[] repoUrlFromRequest(String path) {\n- String[] parts = path.split(\"/\", -1);\n- if (parts.length < 4) return null;\n- if (parts[0].length() != 0) return null;\n- if (!\"github\".equals(parts[1])) return null;\n- String remainingPath = Arrays.asList(parts).subList(4, parts.length).stream().reduce(\"/\", (a, b) -> a + \"/\" + b);\n- if (!remainingPath.startsWith(\"/\")) remainingPath = \"/\" + remainingPath;\n- if (remainingPath.startsWith(\"//\")) remainingPath = remainingPath.substring(1);\n- return new String[]{\n- \"https://github.com/\" + parts[2] + \"/\" + parts[3] + \".git\",\n- remainingPath\n- };\n+ return true;\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/RedirectedURL.java", "diff": "+package org.modelix.uiproxy;\n+\n+import org.apache.commons.codec.digest.DigestUtils;\n+\n+import javax.servlet.http.HttpServletRequest;\n+import java.util.Arrays;\n+\n+public class RedirectedURL {\n+ public static final String DEPLOYMENT_PREFIX = \"ui-git-\";\n+\n+ public static RedirectedURL redirect(HttpServletRequest req) {\n+ String[] parts = req.getRequestURI().split(\"/\", -1);\n+ if (parts.length < 4) return null;\n+ if (parts[0].length() != 0) return null;\n+ if (!\"github\".equals(parts[1])) return null;\n+ String remainingPath = Arrays.asList(parts).subList(4, parts.length).stream().reduce(\"/\", (a, b) -> a + \"/\" + b);\n+ if (!remainingPath.startsWith(\"/\")) remainingPath = \"/\" + remainingPath;\n+ if (remainingPath.startsWith(\"//\")) remainingPath = remainingPath.substring(1);\n+ if (req.getQueryString() != null && req.getQueryString().length() > 0) {\n+ remainingPath += \"?\" + req.getQueryString();\n+ }\n+ return new RedirectedURL(\n+ remainingPath,\n+ \"https://github.com/\" + parts[2] + \"/\" + parts[3] + \".git\"\n+ );\n+ }\n+\n+ private String remainingPath;\n+ private String repositoryUrl;\n+\n+ public RedirectedURL(String remainingPath, String repositoryUrl) {\n+ this.remainingPath = remainingPath;\n+ this.repositoryUrl = repositoryUrl;\n+ }\n+\n+ public String getRemainingPath() {\n+ return remainingPath;\n+ }\n+\n+ public String getRepositoryUrl() {\n+ return repositoryUrl;\n+ }\n+\n+ public String getDeploymentName() {\n+ return DEPLOYMENT_PREFIX + DigestUtils.sha1Hex(getRepositoryUrl());\n+ }\n+\n+ public String getRedirectedUrl(boolean websocket) {\n+ return (websocket ? \"ws\" : \"http\") + \"://\" + getDeploymentName() + \":33333\" + getRemainingPath();\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Show placeholder page while the MPS instance is started
426,496
04.07.2020 11:56:38
-7,200
08aac2a36498d2fcbc86584dade2993ac986f812
A specific commit can now be loaded into the MPS instance
[ { "change_type": "ADD", "old_path": null, "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "+package org.modelix.uiproxy;\n+\n+import io.kubernetes.client.custom.Quantity;\n+import io.kubernetes.client.openapi.ApiException;\n+import io.kubernetes.client.openapi.Configuration;\n+import io.kubernetes.client.openapi.apis.AppsV1Api;\n+import io.kubernetes.client.openapi.apis.CoreV1Api;\n+import io.kubernetes.client.openapi.models.V1Deployment;\n+import io.kubernetes.client.openapi.models.V1DeploymentBuilder;\n+import io.kubernetes.client.openapi.models.V1DeploymentList;\n+import io.kubernetes.client.openapi.models.V1Service;\n+import io.kubernetes.client.openapi.models.V1ServiceBuilder;\n+import io.kubernetes.client.openapi.models.V1ServiceList;\n+import io.kubernetes.client.util.ClientBuilder;\n+import io.kubernetes.client.util.Yaml;\n+import org.apache.log4j.Logger;\n+import org.eclipse.jetty.server.Request;\n+import org.eclipse.jetty.server.handler.AbstractHandler;\n+import org.eclipse.jgit.api.Git;\n+import org.eclipse.jgit.api.errors.GitAPIException;\n+import org.eclipse.jgit.lib.Ref;\n+\n+import javax.servlet.ServletException;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+import java.io.IOException;\n+import java.util.Collection;\n+import java.util.function.Supplier;\n+\n+public class DeploymentManagingHandler extends AbstractHandler {\n+ private static final Logger LOG = Logger.getLogger(DeploymentManagingHandler.class);\n+ @Override\n+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n+ try {\n+ RedirectedURL redirectedURL = RedirectedURL.redirect(request);\n+ if (redirectedURL == null) throw new RuntimeException(\"Invalid request: \" + request.getRequestURI());\n+\n+ if (redirectedURL.getRemainingPath() == null) {\n+ if (request.getRequestURI().endsWith(\"/\")) {\n+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);\n+ } else {\n+ response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);\n+ response.addHeader(\"Location\", request.getRequestURI() + \"/\");\n+ }\n+ baseRequest.setHandled(true);\n+ return;\n+ }\n+\n+ if (redirectedURL.getCommitId() == null) {\n+ Collection<Ref> refs = null;\n+ try {\n+ refs = Git.lsRemoteRepository()\n+ .setRemote(redirectedURL.getRepositoryUrl())\n+ .setTags(true)\n+ .setHeads(true)\n+ .call();\n+ } catch (GitAPIException e) {\n+ throw new RuntimeException(e);\n+ }\n+\n+ response.getWriter()\n+ .append(\"<html>\")\n+ .append(\"<head>\")\n+ .append(\"</head>\")\n+ .append(\"<body>\");\n+\n+ for (Ref ref : refs) {\n+ response.getWriter()\n+ .append(\"<div><a href=\\\"commit/\")\n+ .append(ref.getObjectId().getName())\n+ .append(\"/\\\">\")\n+ .append(ref.getName())\n+ .append(\"</a></div>\");\n+ }\n+\n+ response.getWriter()\n+ .append(\"</body>\")\n+ .append(\"</html>\");\n+ baseRequest.setHandled(true);\n+ response.setContentType(\"text/html\");\n+ response.setStatus(HttpServletResponse.SC_OK);\n+ return;\n+ }\n+\n+ boolean deploymentCreated = createDeployment(redirectedURL, () -> {\n+ Collection<Ref> refs = null;\n+ try {\n+ refs = Git.lsRemoteRepository()\n+ .setRemote(redirectedURL.getRepositoryUrl())\n+ .setTags(false)\n+ .setHeads(true)\n+ .call();\n+ } catch (GitAPIException e) {\n+ LOG.error(\"\", e);\n+ return false;\n+ }\n+ for (Ref ref : refs) {\n+ System.out.println(\"Ref: \" + ref.getName() + \" -> \" + ref.getObjectId().getName());\n+ if (\"refs/heads/master\".equals(ref.getName())) {\n+ System.out.println(\"commit ID: \" + ref.getObjectId().getName());\n+ return true;\n+ }\n+ }\n+ return false;\n+ });\n+ if (!deploymentCreated) throw new RuntimeException(\"Not git repository found at \" + redirectedURL.getRepositoryUrl());\n+\n+ V1Deployment deployment = getDeployment(redirectedURL.getDeploymentName());\n+ if (deployment == null) throw new RuntimeException(\"Failed to create deployment\");\n+\n+ Integer readyReplicas = deployment.getStatus() != null ? deployment.getStatus().getReadyReplicas() : null;\n+ if (readyReplicas == null || readyReplicas == 0) {\n+ baseRequest.setHandled(true);\n+ response.setContentType(\"text/html\");\n+ response.setStatus(HttpServletResponse.SC_OK);\n+ response.getWriter()\n+ .append(\"<html>\")\n+ .append(\"<head>\")\n+ .append(\"<meta http-equiv=\\\"refresh\\\" content=\\\"5\\\">\")\n+ .append(\"</head>\")\n+ .append(\"<body>\")\n+ .append(\"Starting MPS and loading \" + redirectedURL.getRepositoryUrl() + \" ...\")\n+ .append(\"</body>\")\n+ .append(\"</html>\");\n+ }\n+ } catch (Exception ex) {\n+ throw new RuntimeException(ex);\n+ }\n+ }\n+\n+\n+ private boolean isDeploymentReady(String name) throws ApiException {\n+ V1Deployment deployment = getDeployment(name);\n+ if (deployment == null) return false;\n+ return deployment.getStatus().getReadyReplicas() > 0;\n+ }\n+\n+ private V1Deployment getDeployment(String name) throws ApiException {\n+ AppsV1Api appsApi = new AppsV1Api();\n+ V1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, null, null);\n+ for (V1Deployment deployment : deployments.getItems()) {\n+ if (name.equals(deployment.getMetadata().getName())) return deployment;\n+ }\n+ return null;\n+ }\n+\n+ private boolean createDeployment(RedirectedURL gitRepoUrl, Supplier<Boolean> urlValidator) throws IOException, ApiException {\n+ Configuration.setDefaultApiClient(ClientBuilder.cluster().build());\n+\n+ String name = gitRepoUrl.getDeploymentName();\n+\n+ AppsV1Api appsApi = new AppsV1Api();\n+\n+ V1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, 5, false);\n+ boolean deploymentExists = deployments.getItems().stream().anyMatch(d -> name.equals(d.getMetadata().getName()));\n+ if (!deploymentExists) {\n+ long numExisting = deployments.getItems().stream().filter(d -> d.getMetadata().getName().startsWith(RedirectedURL.DEPLOYMENT_PREFIX)).count();\n+ if (numExisting > 10) throw new RuntimeException(\"Too many existing deployments\");\n+\n+ if (!urlValidator.get()) {\n+ return false;\n+ }\n+\n+ V1Deployment deployment = new V1DeploymentBuilder()\n+ .withNewMetadata()\n+ .withName(name)\n+ .addToLabels(\"app\", name)\n+ .endMetadata()\n+ .withNewSpec()\n+ .withNewSelector()\n+ .addToMatchLabels(\"app\", name)\n+ .endSelector()\n+ .withNewTemplate()\n+ .withNewMetadata()\n+ .addToLabels(\"app\", name)\n+ .endMetadata()\n+ .withNewSpec()\n+ .addNewContainer()\n+ .withName(\"ui\")\n+ .withImage(\"modelix/modelix-ui:latest\")\n+ .withImagePullPolicy(\"IfNotPresent\")\n+ .addNewEnv()\n+ .withName(\"GIT_REPO_URI\")\n+ .withValue(gitRepoUrl.getRepositoryUrl())\n+ .endEnv()\n+ .addNewEnv()\n+ .withName(\"GIT_COMMIT_ID\")\n+ .withValue(gitRepoUrl.getCommitId())\n+ .endEnv()\n+ .addNewPort()\n+ .withContainerPort(33333)\n+ .endPort()\n+ .addNewVolumeMount()\n+ .withName(\"modelsecret\")\n+ .withMountPath(\"/secrets/modelsecret\")\n+ .withReadOnly(true)\n+ .endVolumeMount()\n+ .withNewResources()\n+ .addToRequests(\"memory\", new Quantity(\"2.0Gi\"))\n+ .addToRequests(\"cpu\", new Quantity(\"0.8\"))\n+ .addToLimits(\"memory\", new Quantity(\"2.5Gi\"))\n+ .addToLimits(\"cpu\", new Quantity(\"1.5\"))\n+ .endResources()\n+ .withNewReadinessProbe()\n+ .withNewHttpGet()\n+ .withNewPath(\"/health/check\")\n+ .withNewPort(33333)\n+ .endHttpGet()\n+ .withInitialDelaySeconds(10)\n+ .withPeriodSeconds(5)\n+ .withTimeoutSeconds(3)\n+ .endReadinessProbe()\n+ .withNewLivenessProbe()\n+ .withNewHttpGet()\n+ .withNewPath(\"/health/check\")\n+ .withNewPort(33333)\n+ .endHttpGet()\n+ .withInitialDelaySeconds(120)\n+ .withPeriodSeconds(20)\n+ .withTimeoutSeconds(10)\n+ .endLivenessProbe()\n+ .endContainer()\n+ .withNewRestartPolicy(\"Always\")\n+ .addNewVolume()\n+ .withName(\"modelsecret\")\n+ .withNewSecret()\n+ .withNewSecretName(\"modelsecret\")\n+ .endSecret()\n+ .endVolume()\n+ .endSpec()\n+ .endTemplate()\n+ .endSpec()\n+ .build();\n+ System.out.println(\"Creating deployment: \");\n+ System.out.println(Yaml.dump(deployment));\n+ appsApi.createNamespacedDeployment(\"default\", deployment, null, null, null);\n+ }\n+\n+ CoreV1Api coreApi = new CoreV1Api();\n+ V1ServiceList services = coreApi.listNamespacedService(\"default\", null, null, null, null, null, null, null, 5, false);\n+ boolean serviceExists = services.getItems().stream().anyMatch(s -> name.equals(s.getMetadata().getName()));\n+ if (!serviceExists) {\n+ V1Service service = new V1ServiceBuilder()\n+ .withNewMetadata()\n+ .addToLabels(\"app\", name)\n+ .withName(name)\n+ .endMetadata()\n+ .withNewSpec()\n+ .withNewType(\"NodePort\")\n+ .addNewPort()\n+ .withName(\"33333\")\n+ .withPort(33333)\n+ .withNewTargetPort(33333)\n+ .endPort()\n+ .addToSelector(\"app\", name)\n+ .endSpec()\n+ .build();\n+ System.out.println(\"Creating service: \");\n+ System.out.println(Yaml.dump(service));\n+\n+ coreApi.createNamespacedService(\"default\", service, null, null, null);\n+ }\n+\n+ return true;\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "diff": "@@ -45,21 +45,15 @@ import java.util.function.Supplier;\npublic class Main {\nprivate static final Logger LOG = Logger.getLogger(Main.class);\n-\npublic static void main(String[] args) {\ntry {\nstartServer();\n} catch (ApiException ex) {\n- System.out.println(\"code: \" + ex.getCode());\n- System.out.println(\"body: \" + ex.getResponseBody());\n+ LOG.error(\"\", ex);\n+ LOG.error(\"code: \" + ex.getCode());\n+ LOG.error(\"body: \" + ex.getResponseBody());\n} catch (Exception ex) {\nLOG.error(\"\", ex);\n- ex.printStackTrace();\n- Throwable cause = ex.getCause();\n- if (cause != null) {\n- System.out.println(cause.getMessage());\n- cause.printStackTrace();\n- }\n}\n}\n@@ -68,60 +62,7 @@ public class Main {\nHandlerList handlerList = new HandlerList();\nserver.setHandler(handlerList);\n- Handler deploymentManagingHandler = new AbstractHandler() {\n- @Override\n- public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n- try {\n- System.out.println(\"requestURI: \" + request.getRequestURI());\n- RedirectedURL redirectedURL = RedirectedURL.redirect(request);\n- if (redirectedURL == null) throw new RuntimeException(\"Invalid request: \" + request.getRequestURI());\n- System.out.println(\"repo URL: \" + redirectedURL.getRepositoryUrl());\n- boolean deploymentCreated = createDeployment(redirectedURL, () -> {\n- Collection<Ref> refs = null;\n- try {\n- refs = Git.lsRemoteRepository()\n- .setRemote(redirectedURL.getRepositoryUrl())\n- .setTags(false)\n- .setHeads(true)\n- .call();\n- } catch (GitAPIException e) {\n- LOG.error(\"\", e);\n- return false;\n- }\n- for (Ref ref : refs) {\n- System.out.println(\"Ref: \" + ref.getName() + \" -> \" + ref.getObjectId().getName());\n- if (\"refs/heads/master\".equals(ref.getName())) {\n- System.out.println(\"commit ID: \" + ref.getObjectId().getName());\n- return true;\n- }\n- }\n- return false;\n- });\n- if (!deploymentCreated) throw new RuntimeException(\"Not git repository found at \" + redirectedURL.getRepositoryUrl());\n-\n- V1Deployment deployment = getDeployment(redirectedURL.getDeploymentName());\n- if (deployment == null) throw new RuntimeException(\"Failed to create deployment\");\n-\n- Integer readyReplicas = deployment.getStatus() != null ? deployment.getStatus().getReadyReplicas() : null;\n- if (readyReplicas == null || readyReplicas == 0) {\n- baseRequest.setHandled(true);\n- response.setContentType(\"text/html\");\n- response.setStatus(HttpServletResponse.SC_OK);\n- response.getWriter()\n- .append(\"<html>\")\n- .append(\"<head>\")\n- .append(\"<meta http-equiv=\\\"refresh\\\" content=\\\"5\\\">\")\n- .append(\"</head>\")\n- .append(\"<body>\")\n- .append(\"Starting MPS and loading \" + redirectedURL.getRepositoryUrl() + \" ...\")\n- .append(\"</body>\")\n- .append(\"</html>\");\n- }\n- } catch (Exception ex) {\n- throw new RuntimeException(ex);\n- }\n- }\n- };\n+ Handler deploymentManagingHandler = new DeploymentManagingHandler();\nhandlerList.addHandler(deploymentManagingHandler);\nWebSocketServlet webSocketServlet = new WebSocketProxyServlet() {\n@@ -176,135 +117,4 @@ public class Main {\n}\n});\n}\n-\n- private static boolean isDeploymentReady(String name) throws ApiException {\n- V1Deployment deployment = getDeployment(name);\n- if (deployment == null) return false;\n- return deployment.getStatus().getReadyReplicas() > 0;\n- }\n-\n- private static V1Deployment getDeployment(String name) throws ApiException {\n- AppsV1Api appsApi = new AppsV1Api();\n- V1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, null, null);\n- for (V1Deployment deployment : deployments.getItems()) {\n- if (name.equals(deployment.getMetadata().getName())) return deployment;\n- }\n- return null;\n- }\n-\n- private static boolean createDeployment(RedirectedURL gitRepoUrl, Supplier<Boolean> urlValidator) throws IOException, ApiException {\n- Configuration.setDefaultApiClient(ClientBuilder.cluster().build());\n-\n- String name = gitRepoUrl.getDeploymentName();\n-\n- AppsV1Api appsApi = new AppsV1Api();\n-\n- V1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, 5, false);\n- boolean deploymentExists = deployments.getItems().stream().anyMatch(d -> name.equals(d.getMetadata().getName()));\n- if (!deploymentExists) {\n- long numExisting = deployments.getItems().stream().filter(d -> d.getMetadata().getName().startsWith(RedirectedURL.DEPLOYMENT_PREFIX)).count();\n- if (numExisting > 10) throw new RuntimeException(\"Too many existing deployments\");\n-\n- if (!urlValidator.get()) {\n- return false;\n- }\n-\n- V1Deployment deployment = new V1DeploymentBuilder()\n- .withNewMetadata()\n- .withName(name)\n- .addToLabels(\"app\", name)\n- .endMetadata()\n- .withNewSpec()\n- .withNewSelector()\n- .addToMatchLabels(\"app\", name)\n- .endSelector()\n- .withNewTemplate()\n- .withNewMetadata()\n- .addToLabels(\"app\", name)\n- .endMetadata()\n- .withNewSpec()\n- .addNewContainer()\n- .withName(\"ui\")\n- .withImage(\"modelix/modelix-ui:latest\")\n- .withImagePullPolicy(\"IfNotPresent\")\n- .addNewEnv()\n- .withName(\"GIT_REPO_URI\")\n- .withValue(gitRepoUrl.getRepositoryUrl())\n- .endEnv()\n- .addNewPort()\n- .withContainerPort(33333)\n- .endPort()\n- .addNewVolumeMount()\n- .withName(\"modelsecret\")\n- .withMountPath(\"/secrets/modelsecret\")\n- .withReadOnly(true)\n- .endVolumeMount()\n- .withNewResources()\n- .addToRequests(\"memory\", new Quantity(\"2.0Gi\"))\n- .addToRequests(\"cpu\", new Quantity(\"0.8\"))\n- .addToLimits(\"memory\", new Quantity(\"2.5Gi\"))\n- .addToLimits(\"cpu\", new Quantity(\"1.5\"))\n- .endResources()\n- .withNewReadinessProbe()\n- .withNewHttpGet()\n- .withNewPath(\"/health/check\")\n- .withNewPort(33333)\n- .endHttpGet()\n- .withInitialDelaySeconds(10)\n- .withPeriodSeconds(5)\n- .withTimeoutSeconds(3)\n- .endReadinessProbe()\n- .withNewLivenessProbe()\n- .withNewHttpGet()\n- .withNewPath(\"/health/check\")\n- .withNewPort(33333)\n- .endHttpGet()\n- .withInitialDelaySeconds(120)\n- .withPeriodSeconds(20)\n- .withTimeoutSeconds(10)\n- .endLivenessProbe()\n- .endContainer()\n- .withNewRestartPolicy(\"Always\")\n- .addNewVolume()\n- .withName(\"modelsecret\")\n- .withNewSecret()\n- .withNewSecretName(\"modelsecret\")\n- .endSecret()\n- .endVolume()\n- .endSpec()\n- .endTemplate()\n- .endSpec()\n- .build();\n- System.out.println(\"Creating deployment: \");\n- System.out.println(Yaml.dump(deployment));\n- appsApi.createNamespacedDeployment(\"default\", deployment, null, null, null);\n- }\n-\n- CoreV1Api coreApi = new CoreV1Api();\n- V1ServiceList services = coreApi.listNamespacedService(\"default\", null, null, null, null, null, null, null, 5, false);\n- boolean serviceExists = services.getItems().stream().anyMatch(s -> name.equals(s.getMetadata().getName()));\n- if (!serviceExists) {\n- V1Service service = new V1ServiceBuilder()\n- .withNewMetadata()\n- .addToLabels(\"app\", name)\n- .withName(name)\n- .endMetadata()\n- .withNewSpec()\n- .withNewType(\"NodePort\")\n- .addNewPort()\n- .withName(\"33333\")\n- .withPort(33333)\n- .withNewTargetPort(33333)\n- .endPort()\n- .addToSelector(\"app\", name)\n- .endSpec()\n- .build();\n- System.out.println(\"Creating service: \");\n- System.out.println(Yaml.dump(service));\n-\n- coreApi.createNamespacedService(\"default\", service, null, null, null);\n- }\n-\n- return true;\n- }\n}\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/RedirectedURL.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/RedirectedURL.java", "diff": "@@ -4,33 +4,49 @@ import org.apache.commons.codec.digest.DigestUtils;\nimport javax.servlet.http.HttpServletRequest;\nimport java.util.Arrays;\n+import java.util.List;\n+import java.util.Optional;\n+import java.util.stream.Collectors;\npublic class RedirectedURL {\npublic static final String DEPLOYMENT_PREFIX = \"ui-git-\";\npublic static RedirectedURL redirect(HttpServletRequest req) {\n- String[] parts = req.getRequestURI().split(\"/\", -1);\n- if (parts.length < 4) return null;\n- if (parts[0].length() != 0) return null;\n- if (!\"github\".equals(parts[1])) return null;\n- String remainingPath = Arrays.asList(parts).subList(4, parts.length).stream().reduce(\"/\", (a, b) -> a + \"/\" + b);\n- if (!remainingPath.startsWith(\"/\")) remainingPath = \"/\" + remainingPath;\n- if (remainingPath.startsWith(\"//\")) remainingPath = remainingPath.substring(1);\n- if (req.getQueryString() != null && req.getQueryString().length() > 0) {\n+ List<String> parts = Arrays.asList(req.getRequestURI().split(\"/\", -1));\n+ if (parts.size() > 0 && parts.get(0).length() == 0) parts = parts.subList(1, parts.size());\n+\n+ if (parts.size() < 3) return null;\n+ if (!parts.get(0).equals(\"github\")) return null;\n+\n+ String repositoryUrl = \"https://github.com/\" + parts.get(1) + \"/\" + parts.get(2) + \".git\";\n+ parts = parts.subList(3, parts.size());\n+\n+ String commitId = null;\n+ if (parts.size() >= 2 && parts.get(0).equals(\"commit\")) {\n+ commitId = parts.get(1);\n+ parts = parts.subList(2, parts.size());\n+ }\n+\n+ String remainingPath = parts.stream().reduce((a, b) -> a + \"/\" + b).orElse(null);\n+ if (remainingPath != null) remainingPath = \"/\" + remainingPath;\n+ if (remainingPath != null && req.getQueryString() != null && req.getQueryString().length() > 0) {\nremainingPath += \"?\" + req.getQueryString();\n}\nreturn new RedirectedURL(\nremainingPath,\n- \"https://github.com/\" + parts[2] + \"/\" + parts[3] + \".git\"\n+ repositoryUrl,\n+ commitId\n);\n}\nprivate String remainingPath;\nprivate String repositoryUrl;\n+ private String commitId;\n- public RedirectedURL(String remainingPath, String repositoryUrl) {\n+ public RedirectedURL(String remainingPath, String repositoryUrl, String commitId) {\nthis.remainingPath = remainingPath;\nthis.repositoryUrl = repositoryUrl;\n+ this.commitId = commitId;\n}\npublic String getRemainingPath() {\n@@ -41,8 +57,13 @@ public class RedirectedURL {\nreturn repositoryUrl;\n}\n+ public String getCommitId() {\n+ return commitId;\n+ }\n+\npublic String getDeploymentName() {\n- return DEPLOYMENT_PREFIX + DigestUtils.sha1Hex(getRepositoryUrl());\n+ if (getCommitId() == null) throw new RuntimeException(\"No commit ID provided\");\n+ return DEPLOYMENT_PREFIX + DigestUtils.sha1Hex(getRepositoryUrl() + \"@\" + commitId);\n}\npublic String getRedirectedUrl(boolean websocket) {\n" }, { "change_type": "MODIFY", "old_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "new_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "diff": "@@ -4,6 +4,7 @@ import com.google.common.io.Files;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jgit.api.Git;\n+import org.eclipse.jgit.revwalk.RevCommit;\nimport java.io.File;\nimport java.io.IOException;\n@@ -20,18 +21,24 @@ public class Main {\nFile gitRepoDir = null;\n- String gitRepoUri = System.getProperty(\"GIT_REPO_URI\");\n- if (gitRepoUri == null || gitRepoUri.length() == 0) gitRepoUri = System.getenv(\"GIT_REPO_URI\");\n+ String gitRepoUri = getPropertyOrEnv(\"GIT_REPO_URI\");\nif (gitRepoUri != null && gitRepoUri.length() > 0) {\nSystem.out.println(\"Cloning \" + gitRepoUri);\n+ String gitCommitId = getPropertyOrEnv(\"GIT_COMMIT_ID\");\n+ System.out.println(\"Commit ID: \" + gitCommitId);\ngitRepoDir = Files.createTempDir();\nrecursiveDeleteOnExit(gitRepoDir);\nGit git = Git.cloneRepository()\n.setURI(gitRepoUri)\n.setDirectory(gitRepoDir)\n+ .setNoCheckout(gitCommitId != null)\n.call();\n+ if (gitCommitId != null) {\n+ System.out.println(\"Checkout \" + gitCommitId);\n+ git.checkout().setName(gitCommitId).call();\n+ }\nSet<File> files = new HashSet<>();\nSystem.out.println(\"Searching in \" + gitRepoDir);\ncollectMPSFiles(gitRepoDir, files);\n@@ -75,5 +82,11 @@ public class Main {\n}\n});\n}\n+\n+ private static String getPropertyOrEnv(String name) {\n+ String value = System.getProperty(name);\n+ if (value == null || value.length() == 0) value = System.getenv(name);\n+ return value;\n+ }\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
A specific commit can now be loaded into the MPS instance
426,496
04.07.2020 13:41:28
-7,200
c36e9c41811f6dc9faffce6f094ac1bb397fab6f
Cleanup deployments after 10 minutes without access
[ { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "@@ -13,6 +13,7 @@ import io.kubernetes.client.openapi.models.V1ServiceBuilder;\nimport io.kubernetes.client.openapi.models.V1ServiceList;\nimport io.kubernetes.client.util.ClientBuilder;\nimport io.kubernetes.client.util.Yaml;\n+import org.apache.commons.collections4.map.HashedMap;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jetty.server.Request;\nimport org.eclipse.jetty.server.handler.AbstractHandler;\n@@ -25,10 +26,44 @@ import javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\nimport java.io.IOException;\nimport java.util.Collection;\n+import java.util.Collections;\n+import java.util.Map;\n+import java.util.Timer;\n+import java.util.concurrent.Executors;\nimport java.util.function.Supplier;\npublic class DeploymentManagingHandler extends AbstractHandler {\nprivate static final Logger LOG = Logger.getLogger(DeploymentManagingHandler.class);\n+ public static final String KUBERNETES_NAMESPACE = \"default\";\n+\n+ private Map<String, Long> deploymentTimeouts = Collections.synchronizedMap(new HashedMap<>());\n+ private Thread cleanupThread = new Thread() {\n+ @Override\n+ public void run() {\n+ while (true) {\n+ try {\n+ cleanupDeployments();\n+ } catch (Exception ex) {\n+ LOG.error(\"\", ex);\n+ }\n+ try {\n+ Thread.sleep(10_000);\n+ } catch (InterruptedException e) {\n+ return;\n+ }\n+ }\n+ }\n+ };\n+\n+ public DeploymentManagingHandler() {\n+ try {\n+ Configuration.setDefaultApiClient(ClientBuilder.cluster().build());\n+ } catch (IOException e) {\n+ throw new RuntimeException(e);\n+ }\n+ cleanupThread.start();\n+ }\n+\n@Override\npublic void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\ntry {\n@@ -82,6 +117,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\nreturn;\n}\n+ deploymentTimeouts.put(redirectedURL.getDeploymentName(), System.currentTimeMillis() + 600_000);\nboolean deploymentCreated = createDeployment(redirectedURL, () -> {\nCollection<Ref> refs = null;\ntry {\n@@ -123,11 +159,36 @@ public class DeploymentManagingHandler extends AbstractHandler {\n.append(\"</body>\")\n.append(\"</html>\");\n}\n+\n+ cleanupDeployments();\n} catch (Exception ex) {\nthrow new RuntimeException(ex);\n}\n}\n+ private final Object cleanupLock = new Object();\n+ private void cleanupDeployments() {\n+ // TODO doesn't work with multiple instances of UI proxy\n+ synchronized (cleanupLock) {\n+ try {\n+ AppsV1Api appsApi = new AppsV1Api();\n+ CoreV1Api coreApi = new CoreV1Api();\n+ V1DeploymentList deployments = null;\n+ deployments = appsApi.listNamespacedDeployment(KUBERNETES_NAMESPACE, null, null, null, null, null, null, null, null, null);\n+ for (V1Deployment deployment : deployments.getItems()) {\n+ String name = deployment.getMetadata().getName();\n+ if (!name.startsWith(RedirectedURL.DEPLOYMENT_PREFIX)) continue;\n+ Long timeout = deploymentTimeouts.get(name);\n+ if (timeout != null && timeout > System.currentTimeMillis()) continue;\n+ deploymentTimeouts.remove(name);\n+ appsApi.deleteNamespacedDeployment(name, KUBERNETES_NAMESPACE, null, null, null, null, null, null);\n+ coreApi.deleteNamespacedService(name, KUBERNETES_NAMESPACE, null, null, null, null, null, null);\n+ }\n+ } catch (ApiException e) {\n+ LOG.error(\"Deployment cleanup failed\", e);\n+ }\n+ }\n+ }\nprivate boolean isDeploymentReady(String name) throws ApiException {\nV1Deployment deployment = getDeployment(name);\n@@ -137,7 +198,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\nprivate V1Deployment getDeployment(String name) throws ApiException {\nAppsV1Api appsApi = new AppsV1Api();\n- V1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, null, null);\n+ V1DeploymentList deployments = appsApi.listNamespacedDeployment(KUBERNETES_NAMESPACE, null, null, null, null, null, null, null, null, null);\nfor (V1Deployment deployment : deployments.getItems()) {\nif (name.equals(deployment.getMetadata().getName())) return deployment;\n}\n@@ -145,13 +206,11 @@ public class DeploymentManagingHandler extends AbstractHandler {\n}\nprivate boolean createDeployment(RedirectedURL gitRepoUrl, Supplier<Boolean> urlValidator) throws IOException, ApiException {\n- Configuration.setDefaultApiClient(ClientBuilder.cluster().build());\n-\nString name = gitRepoUrl.getDeploymentName();\nAppsV1Api appsApi = new AppsV1Api();\n- V1DeploymentList deployments = appsApi.listNamespacedDeployment(\"default\", null, null, null, null, null, null, null, 5, false);\n+ V1DeploymentList deployments = appsApi.listNamespacedDeployment(KUBERNETES_NAMESPACE, null, null, null, null, null, null, null, 5, false);\nboolean deploymentExists = deployments.getItems().stream().anyMatch(d -> name.equals(d.getMetadata().getName()));\nif (!deploymentExists) {\nlong numExisting = deployments.getItems().stream().filter(d -> d.getMetadata().getName().startsWith(RedirectedURL.DEPLOYMENT_PREFIX)).count();\n@@ -233,11 +292,11 @@ public class DeploymentManagingHandler extends AbstractHandler {\n.build();\nSystem.out.println(\"Creating deployment: \");\nSystem.out.println(Yaml.dump(deployment));\n- appsApi.createNamespacedDeployment(\"default\", deployment, null, null, null);\n+ appsApi.createNamespacedDeployment(KUBERNETES_NAMESPACE, deployment, null, null, null);\n}\nCoreV1Api coreApi = new CoreV1Api();\n- V1ServiceList services = coreApi.listNamespacedService(\"default\", null, null, null, null, null, null, null, 5, false);\n+ V1ServiceList services = coreApi.listNamespacedService(KUBERNETES_NAMESPACE, null, null, null, null, null, null, null, 5, false);\nboolean serviceExists = services.getItems().stream().anyMatch(s -> name.equals(s.getMetadata().getName()));\nif (!serviceExists) {\nV1Service service = new V1ServiceBuilder()\n@@ -258,7 +317,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\nSystem.out.println(\"Creating service: \");\nSystem.out.println(Yaml.dump(service));\n- coreApi.createNamespacedService(\"default\", service, null, null, null);\n+ coreApi.createNamespacedService(KUBERNETES_NAMESPACE, service, null, null, null);\n}\nreturn true;\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Cleanup deployments after 10 minutes without access
426,496
06.07.2020 11:34:59
-7,200
e9f327390a4079a33a72bf805dcacb6c45b1a3e2
Show MPS console output while waiting for the pod to start
[ { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "package org.modelix.uiproxy;\n+import io.kubernetes.client.PodLogs;\nimport io.kubernetes.client.custom.Quantity;\nimport io.kubernetes.client.openapi.ApiException;\nimport io.kubernetes.client.openapi.Configuration;\n@@ -8,12 +9,16 @@ import io.kubernetes.client.openapi.apis.CoreV1Api;\nimport io.kubernetes.client.openapi.models.V1Deployment;\nimport io.kubernetes.client.openapi.models.V1DeploymentBuilder;\nimport io.kubernetes.client.openapi.models.V1DeploymentList;\n+import io.kubernetes.client.openapi.models.V1Pod;\n+import io.kubernetes.client.openapi.models.V1PodList;\nimport io.kubernetes.client.openapi.models.V1Service;\nimport io.kubernetes.client.openapi.models.V1ServiceBuilder;\nimport io.kubernetes.client.openapi.models.V1ServiceList;\nimport io.kubernetes.client.util.ClientBuilder;\nimport io.kubernetes.client.util.Yaml;\nimport org.apache.commons.collections4.map.HashedMap;\n+import org.apache.commons.io.IOUtils;\n+import org.apache.commons.lang.StringEscapeUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jetty.server.Request;\nimport org.eclipse.jetty.server.handler.AbstractHandler;\n@@ -25,6 +30,8 @@ import javax.servlet.ServletException;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\nimport java.io.IOException;\n+import java.io.InputStream;\n+import java.nio.charset.StandardCharsets;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.Map;\n@@ -149,13 +156,23 @@ public class DeploymentManagingHandler extends AbstractHandler {\nbaseRequest.setHandled(true);\nresponse.setContentType(\"text/html\");\nresponse.setStatus(HttpServletResponse.SC_OK);\n+ String podLogs = getPodLogs(redirectedURL.getDeploymentName());\n+\nresponse.getWriter()\n.append(\"<html>\")\n.append(\"<head>\")\n.append(\"<meta http-equiv=\\\"refresh\\\" content=\\\"5\\\">\")\n.append(\"</head>\")\n.append(\"<body>\")\n- .append(\"Starting MPS and loading \" + redirectedURL.getRepositoryUrl() + \" ...\")\n+ .append(\"<div>Starting MPS ...</div>\");\n+\n+ if (podLogs != null) {\n+ response.getWriter().append(\"<br/><hr/><br/><pre>\");\n+ StringEscapeUtils.escapeHtml(response.getWriter(), podLogs);\n+ response.getWriter().append(\"</pre>\");\n+ }\n+\n+ response.getWriter()\n.append(\"</body>\")\n.append(\"</html>\");\n}\n@@ -205,6 +222,26 @@ public class DeploymentManagingHandler extends AbstractHandler {\nreturn null;\n}\n+ private String getPodLogs(String deploymentName) {\n+ try {\n+ CoreV1Api coreApi = new CoreV1Api();\n+ V1PodList pods = coreApi.listNamespacedPod(KUBERNETES_NAMESPACE, null, null, null, null, null, null, null, null, null);\n+ for (V1Pod pod : pods.getItems()) {\n+ if (!pod.getMetadata().getName().startsWith(deploymentName)) continue;\n+ return coreApi.readNamespacedPodLog(\n+ pod.getMetadata().getName(),\n+ KUBERNETES_NAMESPACE,\n+ pod.getSpec().getContainers().get(0).getName(),\n+ null, null, \"true\", null, null, null, null);\n+ }\n+ } catch (Exception e) {\n+ LOG.error(\"\", e);\n+ return null;\n+ }\n+\n+ return null;\n+ }\n+\nprivate boolean createDeployment(RedirectedURL gitRepoUrl, Supplier<Boolean> urlValidator) throws IOException, ApiException {\nString name = gitRepoUrl.getDeploymentName();\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Show MPS console output while waiting for the pod to start
426,496
06.07.2020 11:38:55
-7,200
52d07bfcd61319942609e270893a169a64c4c169
Limit log output to 10_000 lines
[ { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "@@ -232,7 +232,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\npod.getMetadata().getName(),\nKUBERNETES_NAMESPACE,\npod.getSpec().getContainers().get(0).getName(),\n- null, null, \"true\", null, null, null, null);\n+ null, null, \"true\", null, null, 10_000, null);\n}\n} catch (Exception e) {\nLOG.error(\"\", e);\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Limit log output to 10_000 lines
426,496
06.07.2020 12:25:34
-7,200
19c35bbf04fb29fa776ea4088bdd7310481e32e3
Grant cluster editing permissions only to the uiproxy
[ { "change_type": "MODIFY", "old_path": "kubernetes/common/uiproxy-deployment.yaml", "new_path": "kubernetes/common/uiproxy-deployment.yaml", "diff": "@@ -21,6 +21,7 @@ spec:\nlabels:\napp: uiproxy\nspec:\n+ serviceAccountName: uiproxy\ncontainers:\n- image: modelix/modelix-uiproxy:latest\nimagePullPolicy: IfNotPresent\n" }, { "change_type": "RENAME", "old_path": "kubernetes/common/role-binding.yaml", "new_path": "kubernetes/common/uiproxy-rolebinding.yaml", "diff": "kind: ClusterRoleBinding\napiVersion: rbac.authorization.k8s.io/v1\nmetadata:\n- name: editing-for-all\n+ name: uiproxy-edit\nnamespace: default\nsubjects:\n- kind: ServiceAccount\n- name: default\n+ name: uiproxy\nnamespace: default\nroleRef:\nkind: ClusterRole\n" }, { "change_type": "ADD", "old_path": null, "new_path": "kubernetes/common/uiproxy-serviceaccount.yaml", "diff": "+apiVersion: v1\n+kind: ServiceAccount\n+metadata:\n+ name: uiproxy\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Grant cluster editing permissions only to the uiproxy
426,496
06.07.2020 12:26:31
-7,200
6540d36e0664af565143b7d87d91f9a73214f65c
Removed HTML editor from the concept page
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "new_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "diff": "</node>\n</node>\n</node>\n- <node concept=\"027rt\" id=\"7trMQm3mukV\" role=\"02LM9\">\n+ <node concept=\"1X3_iC\" id=\"6pXrrBnvqRk\" role=\"lGtFl\">\n+ <property role=\"3V$3am\" value=\"content\" />\n+ <property role=\"3V$3ak\" value=\"94b64715-a263-4c36-a138-8da14705ffa7/7335687028107243116/7335687028107281653\" />\n+ <node concept=\"027rt\" id=\"7trMQm3mukV\" role=\"8Wnug\">\n<ref role=\"027rv\" to=\"70w2:7NImM053Sep\" resolve=\"children\" />\n<node concept=\"214gnc\" id=\"7trMQm3muDH\" role=\"027rp\">\n<ref role=\"1YEVMl\" node=\"7trMQm3W2UH\" resolve=\"imageNodeEditor\" />\n</node>\n</node>\n</node>\n+ </node>\n<node concept=\"02i3K\" id=\"7trMQm3l_uo\" role=\"02i3f\">\n<node concept=\"02i3D\" id=\"4JrW6YuXsEz\" role=\"02i2B\">\n<ref role=\"02i3$\" to=\"tpck:gw2VY9q\" resolve=\"BaseConcept\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Removed HTML editor from the concept page
426,496
09.07.2020 09:29:55
-7,200
d4a5c74a2ac153e599d5b80db63b01f519cb3f8f
Diff view ...
[ { "change_type": "MODIFY", "old_path": "run-ui-server.sh", "new_path": "run-ui-server.sh", "diff": "java -DMODEL_URI=$MODEL_URI \\\n-DGIT_REPO_URI=$GIT_REPO_URI \\\n-DTREE_ID=$TREE_ID \\\n- -classpath \"./*:./mps/lib/*:./dependencies/*\" \\\n+ -classpath \"./*:./mps/lib/*:./mps/plugins/git4idea/lib/*:./mps/plugins/mps-vcs/lib/*:./dependencies/*\" \\\n-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5071 \\\norg.modelix.ui.server.Main\n" }, { "change_type": "MODIFY", "old_path": "settings.gradle", "new_path": "settings.gradle", "diff": "@@ -3,3 +3,4 @@ rootProject.name = 'modelix'\ninclude 'ui-client'\ninclude 'model-server'\ninclude 'ui-server'\n+include 'ui-proxy'\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "@@ -75,7 +75,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\npublic void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\ntry {\nRedirectedURL redirectedURL = RedirectedURL.redirect(request);\n- if (redirectedURL == null) throw new RuntimeException(\"Invalid request: \" + request.getRequestURI());\n+ if (redirectedURL == null) return;\nif (redirectedURL.getRemainingPath() == null) {\nif (request.getRequestURI().endsWith(\"/\")) {\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/Main.java", "diff": "@@ -70,6 +70,7 @@ public class Main {\nprotected URI redirect(ServletUpgradeRequest request) {\nString path = request.getRequestURI().getPath();\nRedirectedURL redirectedURL = RedirectedURL.redirect(request.getHttpServletRequest());\n+ if (redirectedURL == null) return null;\ntry {\nreturn new URI(redirectedURL.getRedirectedUrl(true));\n} catch (URISyntaxException e) {\n@@ -80,6 +81,7 @@ public class Main {\nHandlerWrapper webSocketHandlerCondition = new HandlerWrapper() {\n@Override\npublic void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {\n+ if (RedirectedURL.redirect(request) == null) return;\nif (!baseRequest.getRequestURI().contains(\"/ws/\")) return;\nsuper.handle(target, baseRequest, request, response);\n}\n@@ -94,9 +96,11 @@ public class Main {\n@Override\nprotected String rewriteTarget(HttpServletRequest clientRequest) {\nRedirectedURL redirectedURL = RedirectedURL.redirect(clientRequest);\n+ if (redirectedURL == null) return null;\nreturn redirectedURL.getRedirectedUrl(false);\n}\n};\n+ proxyServlet.setTimeout(60_000);\nServletContextHandler proxyHandler = new ServletContextHandler();\nproxyHandler.addServlet(new ServletHolder(proxyServlet), \"/*\");\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/WebSocketProxyServlet.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/WebSocketProxyServlet.java", "diff": "@@ -26,7 +26,8 @@ public abstract class WebSocketProxyServlet extends WebSocketServlet {\nfactory.setCreator(new WebSocketCreator() {\n@Override\npublic Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {\n-\n+ URI redirectURL = redirect(req);\n+ if (redirectURL == null) return null;\nreturn new WebSocketListener() {\nprivate WebSocketClient client = new WebSocketClient();\nprivate Session sessionA;\n@@ -38,6 +39,7 @@ public abstract class WebSocketProxyServlet extends WebSocketServlet {\ntry {\nclient.start();\nclient.getPolicy().setMaxTextMessageSize(20 * 1024 * 1024);\n+ URI redirectURL = redirect(req);\nclient.connect(new WebSocketListener() {\n@Override\npublic void onWebSocketBinary(byte[] payload, int offset, int len) {\n@@ -67,7 +69,7 @@ public abstract class WebSocketProxyServlet extends WebSocketServlet {\npublic void onWebSocketError(Throwable cause) {\nLOG.error(\"\", cause);\n}\n- }, redirect(req), new ClientUpgradeRequest()).get();\n+ }, redirectURL, new ClientUpgradeRequest()).get();\n} catch (Exception e) {\nthrow new RuntimeException(e);\n}\n" }, { "change_type": "MODIFY", "old_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "new_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "diff": "package org.modelix.ui.server;\nimport com.google.common.io.Files;\n+import com.intellij.diff.DiffContext;\n+import com.intellij.diff.requests.ContentDiffRequest;\n+import com.intellij.diff.requests.DiffRequest;\n+import com.intellij.dvcs.repo.VcsRepositoryManager;\n+import com.intellij.openapi.progress.EmptyProgressIndicator;\n+import com.intellij.openapi.util.Key;\n+import com.intellij.openapi.util.UserDataHolder;\n+import com.intellij.openapi.util.UserDataHolderBase;\n+import com.intellij.openapi.vcs.changes.Change;\n+import com.intellij.openapi.vcs.changes.actions.diff.ChangeDiffRequestProducer;\n+import com.intellij.openapi.vcs.diff.ItemLatestState;\n+import com.intellij.openapi.vfs.LocalFileSystem;\n+import com.intellij.openapi.vfs.VirtualFile;\n+import com.intellij.vcsUtil.VcsUtil;\n+import git4idea.GitCommit;\n+import git4idea.history.GitHistoryUtils;\n+import git4idea.repo.GitRepository;\n+import git4idea.repo.GitRepositoryImpl;\n+import jetbrains.mps.ide.project.ProjectHelper;\n+import jetbrains.mps.project.MPSProject;\n+import jetbrains.mps.project.Project;\n+import jetbrains.mps.vcs.platform.integration.ModelDiffViewer;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jgit.api.Git;\nimport org.eclipse.jgit.revwalk.RevCommit;\n+import org.jetbrains.annotations.NotNull;\n+import org.jetbrains.annotations.Nullable;\n+import javax.swing.*;\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.HashSet;\n+import java.util.List;\nimport java.util.Set;\npublic class Main {\n@@ -43,6 +69,8 @@ public class Main {\nSystem.out.println(\"Searching in \" + gitRepoDir);\ncollectMPSFiles(gitRepoDir, files);\nfiles.forEach(f -> System.out.println(\"MPS related file found: \" + f));\n+\n+\n}\nLOG.error(\"Test error\");\n@@ -50,10 +78,53 @@ public class Main {\nLOG.info(\"Test info\");\nLOG.debug(\"Test debug\");\nLOG.trace(\"Test trace\");\n- EnvironmentLoader.loadEnvironment(gitRepoDir);\n+ Project mpsProject = EnvironmentLoader.loadEnvironment(gitRepoDir);\nLOG.debug(\"idea.load.plugins.id: \" + System.getProperty(\"idea.load.plugins.id\"));\n+\n+ if (gitRepoDir != null) {\n+ VirtualFile repoRoot = LocalFileSystem.getInstance().findFileByIoFile(gitRepoDir);\n+ final com.intellij.openapi.project.Project project = ((MPSProject) mpsProject).getProject();\n+\n+ VcsRepositoryManager vcsManager = VcsRepositoryManager.getInstance(project);\n+ vcsManager.addExternalRepository(\n+ repoRoot,\n+ GitRepositoryImpl.createInstance(repoRoot, project, vcsManager, false)\n+ );\n+\n+ List<GitCommit> history = GitHistoryUtils.history(project, repoRoot, \"-n1\");\n+ Change change = history.get(0).getChanges().stream().findFirst().orElse(null);\n+ System.out.println(\"Change: \" + change);\n+ DiffContext context = new DiffContext() {\n+ @Nullable\n+ @Override\n+ public com.intellij.openapi.project.Project getProject() {\n+ return project;\n+ }\n+\n+ @Override\n+ public boolean isWindowFocused() {\n+ return false;\n+ }\n+\n+ @Override\n+ public boolean isFocusedInWindow() {\n+ return false;\n+ }\n+\n+ @Override\n+ public void requestFocusInWindow() {\n+\n+ }\n+ };\n+ ChangeDiffRequestProducer changeDiffRequestProducer = ChangeDiffRequestProducer.create(project, change);\n+ System.out.println(\"ChangeDiffRequestProducer: \" + changeDiffRequestProducer);\n+ DiffRequest diffRequest = changeDiffRequestProducer.process(context, new EmptyProgressIndicator());\n+ System.out.println(\"DiffRequest: \" + diffRequest);\n+ JComponent viewer = new ModelDiffViewer(context, (ContentDiffRequest) diffRequest).getComponent();\n+ System.out.println(\"Viewer: \" + viewer);\n+ }\n} catch (Exception ex) {\n- LOG.error(ex);\n+ LOG.error(\"\", ex);\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Diff view ...
426,496
10.07.2020 11:23:02
-7,200
56b9d8544dd2d136ed5f2cb17f3930b9618b22c7
Diff view ... (2)
[ { "change_type": "MODIFY", "old_path": "ui-proxy/build.gradle", "new_path": "ui-proxy/build.gradle", "diff": "@@ -21,6 +21,8 @@ dependencies {\ncompile 'io.kubernetes:client-java:8.0.2'\ncompile group: 'log4j', name: 'log4j', version: '1.2.17'\ncompile group: 'commons-codec', name: 'commons-codec', version: '1.14'\n+ compile group: 'commons-io', name: 'commons-io', version: '2.6'\n+ compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'\next.jettyVersion = '9.4.30.v20200611'\ncompile group: 'org.eclipse.jetty', name: 'jetty-server', version: jettyVersion\n" }, { "change_type": "MODIFY", "old_path": "ui-server/build.gradle", "new_path": "ui-server/build.gradle", "diff": "@@ -16,6 +16,8 @@ repositories {\ndependencies {\ncompileOnly fileTree(dir: '../artifacts/mps/lib', include: '*.jar')\n+ compileOnly fileTree(dir: '../artifacts/mps/plugins/git4idea/lib', include: '*.jar')\n+ compileOnly fileTree(dir: '../artifacts/mps/plugins/mps-vcs/lib', include: '*.jar')\ncompile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.8.0.202006091008-r'\ncompile group: 'commons-io', name: 'commons-io', version: '2.7'\n}\n@@ -25,4 +27,4 @@ task copyRuntimeLibs(type: Copy) {\nfrom configurations.runtime\n}\n-assemble.dependsOn copyRuntimeLibs\n\\ No newline at end of file\n+assemble.finalizedBy(copyRuntimeLibs)\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "new_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "diff": "@@ -5,37 +5,43 @@ import com.intellij.diff.DiffContext;\nimport com.intellij.diff.requests.ContentDiffRequest;\nimport com.intellij.diff.requests.DiffRequest;\nimport com.intellij.dvcs.repo.VcsRepositoryManager;\n+import com.intellij.ide.util.PropertiesComponent;\nimport com.intellij.openapi.progress.EmptyProgressIndicator;\n-import com.intellij.openapi.util.Key;\n-import com.intellij.openapi.util.UserDataHolder;\n-import com.intellij.openapi.util.UserDataHolderBase;\n+import com.intellij.openapi.ui.Splitter;\n+import com.intellij.openapi.vcs.FilePath;\nimport com.intellij.openapi.vcs.changes.Change;\nimport com.intellij.openapi.vcs.changes.actions.diff.ChangeDiffRequestProducer;\n-import com.intellij.openapi.vcs.diff.ItemLatestState;\nimport com.intellij.openapi.vfs.LocalFileSystem;\nimport com.intellij.openapi.vfs.VirtualFile;\n-import com.intellij.vcsUtil.VcsUtil;\n+import com.intellij.util.ui.UIUtil;\nimport git4idea.GitCommit;\nimport git4idea.history.GitHistoryUtils;\n-import git4idea.repo.GitRepository;\nimport git4idea.repo.GitRepositoryImpl;\n-import jetbrains.mps.ide.project.ProjectHelper;\nimport jetbrains.mps.project.MPSProject;\nimport jetbrains.mps.project.Project;\n+import jetbrains.mps.vcs.diff.ui.RootDifferencePane;\n+import jetbrains.mps.vcs.diff.ui.common.DiffModelTree;\nimport jetbrains.mps.vcs.platform.integration.ModelDiffViewer;\nimport org.apache.commons.io.FileUtils;\n+import org.apache.commons.lang3.ObjectUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jgit.api.Git;\n-import org.eclipse.jgit.revwalk.RevCommit;\n-import org.jetbrains.annotations.NotNull;\nimport org.jetbrains.annotations.Nullable;\n+import org.jetbrains.mps.openapi.persistence.PersistenceFacade;\n+import org.jetbrains.mps.openapi.persistence.datasource.FileExtensionDataSourceType;\n+import javax.imageio.ImageIO;\nimport javax.swing.*;\n+import javax.swing.tree.TreePath;\n+import java.awt.*;\n+import java.awt.image.BufferedImage;\nimport java.io.File;\nimport java.io.IOException;\n+import java.util.ArrayList;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Set;\n+import java.util.stream.Collectors;\npublic class Main {\nprivate static final Logger LOG = Logger.getLogger(Main.class);\n@@ -55,6 +61,7 @@ public class Main {\nSystem.out.println(\"Commit ID: \" + gitCommitId);\ngitRepoDir = Files.createTempDir();\n+ System.setProperty(\"GIT_REPO_DIR\", gitRepoDir.getAbsolutePath());\nrecursiveDeleteOnExit(gitRepoDir);\nGit git = Git.cloneRepository()\n.setURI(gitRepoUri)\n@@ -82,6 +89,8 @@ public class Main {\nLOG.debug(\"idea.load.plugins.id: \" + System.getProperty(\"idea.load.plugins.id\"));\nif (gitRepoDir != null) {\n+ PropertiesComponent.getInstance().setValue(RootDifferencePane.class.getName() + \"ShowInspector\", false);\n+\nVirtualFile repoRoot = LocalFileSystem.getInstance().findFileByIoFile(gitRepoDir);\nfinal com.intellij.openapi.project.Project project = ((MPSProject) mpsProject).getProject();\n@@ -92,7 +101,10 @@ public class Main {\n);\nList<GitCommit> history = GitHistoryUtils.history(project, repoRoot, \"-n1\");\n- Change change = history.get(0).getChanges().stream().findFirst().orElse(null);\n+ GitCommit commit = history.get(0);\n+ for (Change change : commit.getChanges()) {\n+ if (!isModel(change)) continue;\n+\nSystem.out.println(\"Change: \" + change);\nDiffContext context = new DiffContext() {\n@Nullable\n@@ -122,12 +134,137 @@ public class Main {\nSystem.out.println(\"DiffRequest: \" + diffRequest);\nJComponent viewer = new ModelDiffViewer(context, (ContentDiffRequest) diffRequest).getComponent();\nSystem.out.println(\"Viewer: \" + viewer);\n+\n+ SwingUtilities.invokeAndWait(() -> {\n+ collectComponents(viewer).stream().filter(c -> c instanceof DiffModelTree).findFirst().ifPresent(tree -> {\n+ DiffModelTree diffTree = (DiffModelTree) tree;\n+ for (int i = 0; i < diffTree.getRowCount(); i++) {\n+ TreePath path = diffTree.getPathForRow(i);\n+ if (!(path.getLastPathComponent() instanceof DiffModelTree.RootTreeNode)) continue;\n+ diffTree.setSelectionPath(path);\n+\n+ layoutDiffView(viewer);\n+\n+ BufferedImage img = paintComponent(viewer);\n+\n+ try {\n+ ImageIO.write(img, \"png\", new File(getAffectedFile(change).getName() + \"_\" + i + \"_diff.png\"));\n+ } catch (IOException e) {\n+ LOG.error(\"\", e);\n+ }\n+ }\n+ });\n+ });\n+ }\n+ System.exit(0);\n}\n} catch (Exception ex) {\nLOG.error(\"\", ex);\n}\n}\n+ private static void layoutDiffView(JComponent viewer) {\n+ viewer.setPreferredSize(null);\n+ List<Component> components = collectComponents(viewer);\n+ components.forEach(c -> c.setPreferredSize(null));\n+ components.stream().filter(c -> c instanceof JTree).map(c -> (JTree) c)\n+ .forEach(c -> c.setVisibleRowCount(c.getRowCount()));\n+ List<Dimension> sizes = components.stream().map(c -> c.getPreferredSize()).collect(Collectors.toList());\n+ viewer.setSize(viewer.getPreferredSize());\n+ viewer.setSize(viewer.getWidth() + 10, viewer.getHeight() + 10);\n+ layoutAll(viewer);\n+\n+ for (int timeout = 5; timeout > 0 ; timeout--) {\n+ for (int timeout2 = 20; timeout2 > 0; timeout2--) {\n+ boolean anySplitterChanged = false;\n+ for (Splitter splitter : components.stream().filter(c -> c instanceof Splitter).map(c -> (Splitter) c).collect(Collectors.toList())) {\n+ float additional1;\n+ float additional2;\n+ float size1;\n+ float size2;\n+ if (splitter.isVertical()) {\n+ additional1 = calcAdditionalRequiredSize(splitter.getFirstComponent()).height;\n+ additional2 = calcAdditionalRequiredSize(splitter.getSecondComponent()).height;\n+ size1 = splitter.getFirstComponent().getHeight();\n+ size2 = splitter.getSecondComponent().getHeight();\n+ } else {\n+ additional1 = calcAdditionalRequiredSize(splitter.getFirstComponent()).width;\n+ additional2 = calcAdditionalRequiredSize(splitter.getSecondComponent()).width;\n+ size1 = splitter.getFirstComponent().getWidth();\n+ size2 = splitter.getSecondComponent().getWidth();\n+ }\n+ float newProportion = (size1 + additional1) / (size1 + size2 + additional1 + additional2);\n+ newProportion = Math.min(1.0f, newProportion);\n+ newProportion = Math.max(0.0f, newProportion);\n+ if (newProportion != splitter.getProportion()) {\n+ anySplitterChanged = true;\n+ splitter.setProportion(newProportion);\n+ layoutAll(viewer);\n+ }\n+ }\n+ if (!anySplitterChanged) break;\n+ }\n+\n+\n+ Dimension additionalRequiredSize = calcAdditionalRequiredSize(viewer);\n+ Dimension size = viewer.getSize();\n+ viewer.setSize(new Dimension(size.width + additionalRequiredSize.width, size.height + additionalRequiredSize.height));\n+ layoutAll(viewer);\n+ if (additionalRequiredSize.equals(new Dimension(0, 0))) break;\n+ }\n+ }\n+\n+ private static BufferedImage paintComponent(JComponent component) {\n+ BufferedImage img = UIUtil.createImage(component, component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB);\n+ Graphics2D g = img.createGraphics();\n+ g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);\n+ g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);\n+ g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);\n+\n+ component.paint(g);\n+ return img;\n+ }\n+\n+ private static Dimension calcAdditionalRequiredSize(Component component) {\n+ return collectComponents(component).stream().filter(c -> !(c.getParent() instanceof JScrollPane)).map(c -> {\n+ Dimension preferredSize = c.getPreferredSize();\n+ Dimension size = c.getSize();\n+ return new Dimension(Math.max(0, preferredSize.width - size.width), Math.max(0, preferredSize.height - size.height));\n+ }).reduce(new Dimension(0, 0), (a, b) -> new Dimension(Math.max(a.width, b.width), Math.max(a.height, b.height)));\n+ }\n+\n+ private static List<Component> collectComponents(Component comp) {\n+ List<Component> acc = new ArrayList<>();\n+ collectComponents(comp, acc);\n+ return acc;\n+ }\n+ private static void collectComponents(Component comp, List<Component> acc) {\n+ acc.add(comp);\n+ if (comp instanceof Container) {\n+ for (Component child : ((Container) comp).getComponents()) {\n+ collectComponents(child, acc);\n+ }\n+ }\n+ }\n+\n+ private static void layoutAll(Component comp) {\n+ comp.doLayout();\n+ if (comp instanceof Container) {\n+ for (Component child : ((Container) comp).getComponents()) {\n+ layoutAll(child);\n+ }\n+ }\n+ }\n+\n+ private static FilePath getAffectedFile(Change change) {\n+ return ObjectUtils.firstNonNull(change.getAfterRevision(), change.getBeforeRevision()).getFile();\n+ }\n+\n+ private static boolean isModel(Change change) {\n+ String ext = getAffectedFile(change).getFileType().getDefaultExtension();\n+ return PersistenceFacade.getInstance().getModelFactory(FileExtensionDataSourceType.of(ext)) != null;\n+ }\n+\nprivate static void collectMPSFiles(File file, Set<File> acc) {\nString name = file.getName().toLowerCase();\nif (name.endsWith(\".mps\") || name.endsWith(\".mpl\") || name.endsWith(\".msd\") || name.endsWith(\".devkit\")) {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Diff view ... (2)
426,504
16.07.2020 17:41:31
-7,200
0b97ecd51d012f19be50a222eec43b4057208ff2
add JCommander to deps
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -14,9 +14,9 @@ targetCompatibility = 1.8\ndefaultTasks 'build'\nrepositories {\n-\nmaven { url \"https://repo.maven.apache.org/maven2\" }\n}\n+\ndependencies {\ncompile group: 'org.json', name: 'json', version:'20180813'\ncompile group: 'org.java-websocket', name: 'Java-WebSocket', version:'1.4.0'\n@@ -26,7 +26,7 @@ dependencies {\ncompile group: 'org.apache.ignite', name: 'ignite-core', version:'2.7.5'\ncompile group: 'org.apache.ignite', name: 'ignite-spring', version:'2.7.5'\ncompile group: 'org.apache.ignite', name: 'ignite-indexing', version:'2.7.5'\n- compile group: 'org.postgresql', name: 'postgresql', version:'42.2.6'\n+ compile group: 'org.postgresql', name: 'postgresql', version:'42.2.14'\ncompile group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.4.21.v20190926'\ncompile group: 'org.eclipse.jetty.websocket', name: 'websocket-servlet', version: '9.4.21.v20190926'\n@@ -36,7 +36,7 @@ dependencies {\ncompile group: 'commons-io', name: 'commons-io', version: '2.6'\ncompile group: 'com.google.guava', name: 'guava', version: '28.1-jre'\n-\n+ compile group: 'com.beust', name: 'jcommander', version: '1.7'\n}\ntask copyLibs(type: Copy) {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/main/java/org/modelix/model/server/FileConverter.java", "diff": "+package org.modelix.model.server;\n+\n+import com.beust.jcommander.IStringConverter;\n+\n+import java.io.File;\n+\n+class FileConverter implements IStringConverter<File> {\n+ @Override\n+ public File convert(String value) {\n+ System.out.println(\"Converting \" + value);\n+ if (value == null) {\n+ return null;\n+ }\n+ return new File(value);\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add JCommander to deps
426,504
16.07.2020 17:42:28
-7,200
ac57d41290a7c99d476f8f90dcf483e4aa5f2a70
make jdbc properties and secret path configurable from command line
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/FileConverter.java", "new_path": "model-server/src/main/java/org/modelix/model/server/FileConverter.java", "diff": "@@ -4,10 +4,9 @@ import com.beust.jcommander.IStringConverter;\nimport java.io.File;\n-class FileConverter implements IStringConverter<File> {\n+public class FileConverter implements IStringConverter<File> {\n@Override\npublic File convert(String value) {\n- System.out.println(\"Converting \" + value);\nif (value == null) {\nreturn null;\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IgniteStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IgniteStoreClient.java", "diff": "@@ -4,11 +4,19 @@ import com.google.common.collect.MultimapBuilder;\nimport com.google.common.collect.SetMultimap;\nimport org.apache.ignite.Ignite;\nimport org.apache.ignite.IgniteCache;\n+import org.apache.ignite.IgniteCheckedException;\nimport org.apache.ignite.Ignition;\n+import org.apache.ignite.configuration.IgniteConfiguration;\n+import org.apache.ignite.internal.IgnitionEx;\n+import javax.annotation.Nullable;\n+import java.io.File;\n+import java.io.FileReader;\n+import java.io.IOException;\nimport java.util.HashSet;\nimport java.util.List;\nimport java.util.Map;\n+import java.util.Properties;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.ScheduledExecutorService;\nimport java.util.stream.Collectors;\n@@ -20,7 +28,25 @@ public class IgniteStoreClient implements IStoreClient {\nprivate ScheduledExecutorService timer = Executors.newScheduledThreadPool(1);\nprivate final SetMultimap<String, IKeyListener> listeners = MultimapBuilder.hashKeys().hashSetValues().build();\n- public IgniteStoreClient() {\n+ public IgniteStoreClient(@Nullable File jdbcConfFile) {\n+ if (jdbcConfFile != null) {\n+ // Given that systemPropertiesMode is set to 2 (SYSTEM_PROPERTIES_MODE_OVERRIDE) in ignite.xml, we can override\n+ // the properties through system properties\n+ try {\n+ Properties properties = new Properties();\n+ properties.load(new FileReader(jdbcConfFile));\n+ for (String pn : properties.stringPropertyNames()) {\n+ if (pn.startsWith(\"jdbc.\")) {\n+ System.setProperty(pn, properties.getProperty(pn));\n+ } else {\n+ throw new RuntimeException(\"Properties not related to jdbc are not permitted. Check file \" + jdbcConfFile.getAbsolutePath());\n+ }\n+ }\n+ } catch (IOException e) {\n+ throw new RuntimeException(\"We are unable to load the JDBC configuration from \" + jdbcConfFile.getAbsolutePath(), e);\n+ }\n+ }\n+\nthis.ignite = Ignition.start(getClass().getResource(\"ignite.xml\"));\ncache = ignite.getOrCreateCache(\"model\");\n// timer.scheduleAtFixedRate(() -> {\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\n+import com.beust.jcommander.IStringConverter;\n+import com.beust.jcommander.JCommander;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io.IOUtils;\nimport org.apache.log4j.Logger;\n@@ -32,18 +32,35 @@ import java.util.ArrayList;\nimport java.util.List;\nimport java.util.UUID;\n+import com.beust.jcommander.Parameter;\n+\n+class CmdLineArgs {\n+\n+ @Parameter(names = \"-secret\", description = \"Path to the secretfile\", converter = FileConverter.class)\n+ File secretFile = new File(\"/secrets/modelsecret/modelsecret.txt\");\n+\n+ @Parameter(names = \"-jdbcconf\", description = \"Path to the JDBC configuration file\", converter = FileConverter.class)\n+ File jdbcConfFile = null;\n+}\n+\npublic class Main {\nprivate static final Logger LOG = Logger.getLogger(Main.class);\nprivate static final String REPOSITORY_ID_KEY = \"repositoryId\";\nprivate static String sharedSecret;\n+\npublic static void main(String[] args) {\n+ CmdLineArgs cmdLineArgs = new CmdLineArgs();\n+ new JCommander(cmdLineArgs).parse(args);\n+\nSystem.out.println(\"Max memory (bytes): \" + Runtime.getRuntime().maxMemory());\nSystem.out.println(\"Server process started\");\n+ System.out.println(\"Path to secret file: \" + cmdLineArgs.secretFile);\n+ System.out.println(\"Path to JDBC configuration file: \" + cmdLineArgs.jdbcConfFile);\nSystem.out.println(\"Waiting \");\ntry {\n- File sharedSecretFile = new File(\"/secrets/modelsecret/modelsecret.txt\");\n+ File sharedSecretFile = cmdLineArgs.secretFile;\nif (sharedSecretFile.exists()) {\nsharedSecret = FileUtils.readFileToString(sharedSecretFile, StandardCharsets.UTF_8);\n}\n@@ -51,7 +68,7 @@ public class Main {\nString portStr = System.getenv(\"PORT\");\nInetSocketAddress bindTo = new InetSocketAddress(InetAddress.getByName(\"0.0.0.0\"),\nportStr == null ? 28101 : Integer.parseInt(portStr));\n- IgniteStoreClient storeClient = new IgniteStoreClient();\n+ IgniteStoreClient storeClient = new IgniteStoreClient(cmdLineArgs.jdbcConfFile);\nModelServer modelServer = new ModelServer(storeClient);\nfinal Server server = new Server(bindTo);\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
make jdbc properties and secret path configurable from command line
426,504
16.07.2020 17:44:52
-7,200
ea3025b830585dba32b6098711e11d7aad6ca5d3
explain how to launch model-server with custom JDBC configuration
[ { "change_type": "MODIFY", "old_path": "model-server/README.md", "new_path": "model-server/README.md", "diff": "-# webmps-server\n\\ No newline at end of file\n+# model-server\n+\n+To run the model-server with default configuration run:\n+\n+```\n+./gradlew run'\n+```\n+\n+You may also want to specify a different jdbc configuration. You can do that in this way:\n+\n+```\n+./gradlew run --args='-jdbcconf path-to-my-database.properties'\n+```\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
explain how to launch model-server with custom JDBC configuration
426,504
17.07.2020 09:00:06
-7,200
c6c143aa1af22bde768ded8d6d36e9e1a2658b12
remove the 'Generated by MPS' comment
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/CachingStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/CachingStoreClient.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\nimport org.apache.commons.collections4.map.LRUMap;\nimport java.util.List;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IKeyListener.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IKeyListener.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\n-\npublic interface IKeyListener {\nvoid changed(String key, String value);\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IStoreClient.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\n-\nimport java.util.List;\npublic interface IStoreClient {\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/MessageHandler.java", "new_path": "model-server/src/main/java/org/modelix/model/server/MessageHandler.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\nimport org.eclipse.jetty.websocket.api.RemoteEndpoint;\nimport org.json.JSONObject;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\nimport org.apache.log4j.Level;\nimport org.apache.log4j.LogManager;\nimport org.apache.log4j.Logger;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RedisStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RedisStoreClient.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\nimport io.lettuce.core.RedisClient;\nimport io.lettuce.core.api.StatefulRedisConnection;\nimport io.lettuce.core.api.sync.RedisCommands;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Session.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Session.java", "diff": "package org.modelix.model.server;\n-/*Generated by MPS */\n-\nimport org.eclipse.jetty.websocket.api.RemoteEndpoint;\nimport org.java_websocket.WebSocket;\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
remove the 'Generated by MPS' comment
426,504
17.07.2020 09:09:10
-7,200
01afb4aeefbbe912c84b3b443e5742f7487e2fbc
add license header to source files
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "plugins {\nid \"application\"\n+ id \"com.diffplug.gradle.spotless\" version \"4.5.1\"\n}\napply plugin: 'java'\n@@ -49,3 +50,27 @@ assemble.finalizedBy(copyLibs)\napplication {\nmainClassName = \"org.modelix.model.server.Main\"\n}\n+\n+spotless {\n+ java {\n+ licenseHeader '/*\\n' +\n+ ' * Licensed to the Apache Software Foundation (ASF) under one\\n' +\n+ ' * or more contributor license agreements. See the NOTICE file\\n' +\n+ ' * distributed with this work for additional information\\n' +\n+ ' * regarding copyright ownership. The ASF licenses this file\\n' +\n+ ' * to you under the Apache License, Version 2.0 (the\\n' +\n+ ' * \"License\"); you may not use this file except in compliance\\n' +\n+ ' * with the License. You may obtain a copy of the License at\\n' +\n+ ' *\\n' +\n+ ' * http://www.apache.org/licenses/LICENSE-2.0\\n' +\n+ ' *\\n' +\n+ ' * Unless required by applicable law or agreed to in writing,\\n' +\n+ ' * software distributed under the License is distributed on an\\n' +\n+ ' * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\\n' +\n+ ' * KIND, either express or implied. See the License for the\\n' +\n+ ' * specific language governing permissions and limitations\\n' +\n+ ' * under the License. \\n' +\n+ ' */\\n' +\n+ '\\n'\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/CachingStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/CachingStoreClient.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport org.apache.commons.collections4.map.LRUMap;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ClientIdProcessor.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ClientIdProcessor.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport javax.cache.processor.EntryProcessor;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/FileConverter.java", "new_path": "model-server/src/main/java/org/modelix/model/server/FileConverter.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport com.beust.jcommander.IStringConverter;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IKeyListener.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IKeyListener.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\npublic interface IKeyListener {\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IStoreClient.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport java.util.List;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IgniteStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IgniteStoreClient.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport com.google.common.collect.MultimapBuilder;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/MessageHandler.java", "new_path": "model-server/src/main/java/org/modelix/model/server/MessageHandler.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport org.eclipse.jetty.websocket.api.RemoteEndpoint;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport org.apache.log4j.Level;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ModelServerServlet.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ModelServerServlet.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport org.eclipse.jetty.websocket.api.RemoteEndpoint;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RedisStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RedisStoreClient.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport io.lettuce.core.RedisClient;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Session.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Session.java", "diff": "+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements. See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership. The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\npackage org.modelix.model.server;\nimport org.eclipse.jetty.websocket.api.RemoteEndpoint;\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add license header to source files
426,504
17.07.2020 09:14:38
-7,200
db03c336f046b30c5a71398e2bee817cb491df4c
formatting the codebase
[ { "change_type": "MODIFY", "old_path": "model-server/README.md", "new_path": "model-server/README.md", "diff": "@@ -11,3 +11,11 @@ You may also want to specify a different jdbc configuration. You can do that in\n```\n./gradlew run --args='-jdbcconf path-to-my-database.properties'\n```\n+\n+## Development\n+\n+To reformat and add license header to all files run:\n+\n+```\n+./gradlew spotlessApply\n+```\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -53,6 +53,7 @@ application {\nspotless {\njava {\n+ googleJavaFormat('1.8').aosp()\nlicenseHeader '/*\\n' +\n' * Licensed to the Apache Software Foundation (ASF) under one\\n' +\n' * or more contributor license agreements. See the NOTICE file\\n' +\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/CachingStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/CachingStoreClient.java", "diff": "package org.modelix.model.server;\n-import org.apache.commons.collections4.map.LRUMap;\n-\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Objects;\nimport java.util.UUID;\nimport java.util.stream.Collectors;\n+import org.apache.commons.collections4.map.LRUMap;\npublic class CachingStoreClient implements IStoreClient {\nprivate static final String NULL_STRING = UUID.randomUUID().toString();\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ClientIdProcessor.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ClientIdProcessor.java", "diff": "@@ -25,7 +25,8 @@ import javax.cache.processor.MutableEntry;\npublic class ClientIdProcessor implements EntryProcessor<String, String, Long> {\n@Override\n- public Long process(MutableEntry<String, String> mutableEntry, Object... objects) throws EntryProcessorException {\n+ public Long process(MutableEntry<String, String> mutableEntry, Object... objects)\n+ throws EntryProcessorException {\nString idStr = mutableEntry.getValue();\nlong id = idStr == null ? 0 : Long.parseLong(idStr);\nid++;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/FileConverter.java", "new_path": "model-server/src/main/java/org/modelix/model/server/FileConverter.java", "diff": "package org.modelix.model.server;\nimport com.beust.jcommander.IStringConverter;\n-\nimport java.io.File;\npublic class FileConverter implements IStringConverter<File> {\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IStoreClient.java", "diff": "@@ -23,10 +23,14 @@ import java.util.List;\npublic interface IStoreClient {\nString get(String key);\n+\nList<String> getAll(List<String> keys);\n+\nvoid put(String key, String value);\nvoid listen(final String key, final IKeyListener listener);\n+\nvoid removeListener(final String key, final IKeyListener listener);\n+\nlong generateId(String key);\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/IgniteStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/IgniteStoreClient.java", "diff": "@@ -21,14 +21,6 @@ package org.modelix.model.server;\nimport com.google.common.collect.MultimapBuilder;\nimport com.google.common.collect.SetMultimap;\n-import org.apache.ignite.Ignite;\n-import org.apache.ignite.IgniteCache;\n-import org.apache.ignite.IgniteCheckedException;\n-import org.apache.ignite.Ignition;\n-import org.apache.ignite.configuration.IgniteConfiguration;\n-import org.apache.ignite.internal.IgnitionEx;\n-\n-import javax.annotation.Nullable;\nimport java.io.File;\nimport java.io.FileReader;\nimport java.io.IOException;\n@@ -39,17 +31,23 @@ import java.util.Properties;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.ScheduledExecutorService;\nimport java.util.stream.Collectors;\n+import javax.annotation.Nullable;\n+import org.apache.ignite.Ignite;\n+import org.apache.ignite.IgniteCache;\n+import org.apache.ignite.Ignition;\npublic class IgniteStoreClient implements IStoreClient {\nprivate Ignite ignite;\nprivate IgniteCache<String, String> cache;\nprivate ScheduledExecutorService timer = Executors.newScheduledThreadPool(1);\n- private final SetMultimap<String, IKeyListener> listeners = MultimapBuilder.hashKeys().hashSetValues().build();\n+ private final SetMultimap<String, IKeyListener> listeners =\n+ MultimapBuilder.hashKeys().hashSetValues().build();\npublic IgniteStoreClient(@Nullable File jdbcConfFile) {\nif (jdbcConfFile != null) {\n- // Given that systemPropertiesMode is set to 2 (SYSTEM_PROPERTIES_MODE_OVERRIDE) in ignite.xml, we can override\n+ // Given that systemPropertiesMode is set to 2 (SYSTEM_PROPERTIES_MODE_OVERRIDE) in\n+ // ignite.xml, we can override\n// the properties through system properties\ntry {\nProperties properties = new Properties();\n@@ -58,11 +56,16 @@ public class IgniteStoreClient implements IStoreClient {\nif (pn.startsWith(\"jdbc.\")) {\nSystem.setProperty(pn, properties.getProperty(pn));\n} else {\n- throw new RuntimeException(\"Properties not related to jdbc are not permitted. Check file \" + jdbcConfFile.getAbsolutePath());\n+ throw new RuntimeException(\n+ \"Properties not related to jdbc are not permitted. Check file \"\n+ + jdbcConfFile.getAbsolutePath());\n}\n}\n} catch (IOException e) {\n- throw new RuntimeException(\"We are unable to load the JDBC configuration from \" + jdbcConfFile.getAbsolutePath(), e);\n+ throw new RuntimeException(\n+ \"We are unable to load the JDBC configuration from \"\n+ + jdbcConfFile.getAbsolutePath(),\n+ e);\n}\n}\n@@ -96,7 +99,10 @@ public class IgniteStoreClient implements IStoreClient {\nboolean wasSubscribed = listeners.containsKey(key);\nlisteners.put(key, listener);\nif (!wasSubscribed) {\n- ignite.message().localListen(key, (nodeId, value) -> {\n+ ignite.message()\n+ .localListen(\n+ key,\n+ (nodeId, value) -> {\nif (value instanceof String) {\nsynchronized (listeners) {\nfor (IKeyListener l : listeners.get(key)) {\n@@ -130,5 +136,4 @@ public class IgniteStoreClient implements IStoreClient {\npublic void dispose() {\nignite.close();\n}\n-\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "package org.modelix.model.server;\n-\n-import com.beust.jcommander.IStringConverter;\nimport com.beust.jcommander.JCommander;\n+import com.beust.jcommander.Parameter;\n+import java.io.File;\n+import java.io.IOException;\n+import java.net.InetAddress;\n+import java.net.InetSocketAddress;\n+import java.nio.charset.StandardCharsets;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.UUID;\n+import javax.servlet.ServletException;\n+import javax.servlet.ServletRequest;\n+import javax.servlet.http.HttpServlet;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.commons.io.IOUtils;\nimport org.apache.log4j.Logger;\n@@ -37,28 +49,18 @@ import org.jetbrains.annotations.NotNull;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n-import javax.servlet.ServletException;\n-import javax.servlet.ServletRequest;\n-import javax.servlet.http.HttpServlet;\n-import javax.servlet.http.HttpServletRequest;\n-import javax.servlet.http.HttpServletResponse;\n-import java.io.File;\n-import java.io.IOException;\n-import java.net.InetAddress;\n-import java.net.InetSocketAddress;\n-import java.nio.charset.StandardCharsets;\n-import java.util.ArrayList;\n-import java.util.List;\n-import java.util.UUID;\n-\n-import com.beust.jcommander.Parameter;\n-\nclass CmdLineArgs {\n- @Parameter(names = \"-secret\", description = \"Path to the secretfile\", converter = FileConverter.class)\n+ @Parameter(\n+ names = \"-secret\",\n+ description = \"Path to the secretfile\",\n+ converter = FileConverter.class)\nFile secretFile = new File(\"/secrets/modelsecret/modelsecret.txt\");\n- @Parameter(names = \"-jdbcconf\", description = \"Path to the JDBC configuration file\", converter = FileConverter.class)\n+ @Parameter(\n+ names = \"-jdbcconf\",\n+ description = \"Path to the JDBC configuration file\",\n+ converter = FileConverter.class)\nFile jdbcConfFile = null;\n}\n@@ -85,7 +87,9 @@ public class Main {\n}\nString portStr = System.getenv(\"PORT\");\n- InetSocketAddress bindTo = new InetSocketAddress(InetAddress.getByName(\"0.0.0.0\"),\n+ InetSocketAddress bindTo =\n+ new InetSocketAddress(\n+ InetAddress.getByName(\"0.0.0.0\"),\nportStr == null ? 28101 : Integer.parseInt(portStr));\nIgniteStoreClient storeClient = new IgniteStoreClient(cmdLineArgs.jdbcConfFile);\nModelServer modelServer = new ModelServer(storeClient);\n@@ -96,18 +100,26 @@ public class Main {\n}\nServletContextHandler servletHandler = new ServletContextHandler();\n- servletHandler.addServlet(new ServletHolder(new ModelServerServlet(modelServer)), \"/ws\");\n+ servletHandler.addServlet(\n+ new ServletHolder(new ModelServerServlet(modelServer)), \"/ws\");\n+\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n+ private String HEALTH_KEY =\n+ ModelServer.PROTECTED_PREFIX + \"health2\";\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n- private String HEALTH_KEY = ModelServer.PROTECTED_PREFIX + \"health2\";\n@Override\n- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doGet(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (isHealthy()) {\nresp.setStatus(HttpServletResponse.SC_OK);\nresp.setContentType(\"text/plain\");\nresp.getWriter().print(\"healthy\");\n} else {\n- resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n+ resp.setStatus(\n+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\nresp.setContentType(\"text/plain\");\nresp.getWriter().print(\"not healthy\");\n}\n@@ -121,17 +133,26 @@ public class Main {\n}\nprivate long toLong(String value) {\n- return value == null || value.isEmpty() ? 0 : Long.parseLong(value);\n+ return value == null || value.isEmpty()\n+ ? 0\n+ : Long.parseLong(value);\n}\n- }), \"/health\");\n+ }),\n+ \"/health\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doGet(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\nString key = req.getPathInfo().substring(1);\n- if (key.startsWith(ModelServer.PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n+ if (key.startsWith(ModelServer.PROTECTED_PREFIX))\n+ throw new RuntimeException(\n+ \"No permission to access \" + key);\nString value = storeClient.get(key);\nif (value == null) {\nresp.setStatus(HttpServletResponse.SC_NOT_FOUND);\n@@ -140,11 +161,16 @@ public class Main {\nresp.getWriter().print(value);\n}\n}\n- }), \"/get/*\");\n+ }),\n+ \"/get/*\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doGet(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nString email = req.getHeader(\"X-Forwarded-Email\");\nif ((email == null || email.isEmpty()) && isLocalhost(req)) {\nemail = \"localhost\";\n@@ -157,74 +183,120 @@ public class Main {\n}\nString token = randomUUID();\n- storeClient.put(ModelServer.PROTECTED_PREFIX + \"_token_email_\" + token, email);\n- storeClient.put(ModelServer.PROTECTED_PREFIX + \"_token_expires_\" + token,\n- Long.toString(System.currentTimeMillis() + 7*24*60*60*1000));\n+ storeClient.put(\n+ ModelServer.PROTECTED_PREFIX + \"_token_email_\" + token,\n+ email);\n+ storeClient.put(\n+ ModelServer.PROTECTED_PREFIX\n+ + \"_token_expires_\"\n+ + token,\n+ Long.toString(\n+ System.currentTimeMillis()\n+ + 7 * 24 * 60 * 60 * 1000));\nresp.setContentType(\"text/plain\");\nresp.getWriter().print(token);\n}\n- }), \"/generateToken\");\n+ }),\n+ \"/generateToken\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doGet(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\nString token = extractToken(req);\n- String email = storeClient.get(ModelServer.PROTECTED_PREFIX + \"_token_email_\" + token);\n+ String email =\n+ storeClient.get(\n+ ModelServer.PROTECTED_PREFIX\n+ + \"_token_email_\"\n+ + token);\nresp.setContentType(\"text/plain\");\nresp.getWriter().print(email);\n}\n- }), \"/getEmail\");\n+ }),\n+ \"/getEmail\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doPost(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\nString key = req.getPathInfo().substring(1);\n- if (key.startsWith(ModelServer.PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n+ if (key.startsWith(ModelServer.PROTECTED_PREFIX))\n+ throw new RuntimeException(\n+ \"No permission to access \" + key);\nlong value = storeClient.generateId(key);\nresp.setContentType(\"text/plain\");\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(Long.toString(value));\n}\n- }), \"/counter/*\");\n+ }),\n+ \"/counter/*\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doGet(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\nString key = req.getPathInfo().substring(1);\nresp.setContentType(\"application/json\");\nresp.getWriter().print(modelServer.collect(key).toString(2));\n}\n- }), \"/getRecursively/*\");\n+ }),\n+ \"/getRecursively/*\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doPut(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\nString key = req.getPathInfo().substring(1);\n- if (REPOSITORY_ID_KEY.equals(key)) throw new RuntimeException(\"Changing '\" + key + \"' is not allowed\");\n- if (key.startsWith(ModelServer.PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n- String value = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8);\n+ if (REPOSITORY_ID_KEY.equals(key))\n+ throw new RuntimeException(\n+ \"Changing '\" + key + \"' is not allowed\");\n+ if (key.startsWith(ModelServer.PROTECTED_PREFIX))\n+ throw new RuntimeException(\n+ \"No permission to access \" + key);\n+ String value =\n+ IOUtils.toString(\n+ req.getInputStream(), StandardCharsets.UTF_8);\nstoreClient.put(key, value);\nresp.setStatus(HttpServletResponse.SC_OK);\nresp.setContentType(\"text/plain\");\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(\"OK\");\n}\n- }), \"/put/*\");\n+ }),\n+ \"/put/*\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doPut(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\n- String jsonStr = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8);\n+ String jsonStr =\n+ IOUtils.toString(\n+ req.getInputStream(), StandardCharsets.UTF_8);\nJSONArray json = new JSONArray(jsonStr);\nfor (Object entry_ : json) {\nJSONObject entry = (JSONObject) entry_;\n@@ -246,14 +318,21 @@ public class Main {\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(json.length() + \" entries written\");\n}\n- }), \"/putAll\");\n+ }),\n+ \"/putAll\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doPut(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\n- String reqJsonStr = IOUtils.toString(req.getInputStream(), StandardCharsets.UTF_8);\n+ String reqJsonStr =\n+ IOUtils.toString(\n+ req.getInputStream(), StandardCharsets.UTF_8);\nJSONArray reqJson = new JSONArray(reqJsonStr);\nJSONArray respJson = new JSONArray();\nList<String> keys = new ArrayList<String>(reqJson.length());\n@@ -280,25 +359,36 @@ public class Main {\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(respJson.toString());\n}\n- }), \"/getAll\");\n+ }),\n+ \"/getAll\");\n- servletHandler.addServlet(new ServletHolder(new HttpServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new HttpServlet() {\n@Override\n- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doGet(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nresp.setContentType(\"text/plain\");\nresp.getWriter().println(\"Model Server\");\n}\n- }), \"/\");\n+ }),\n+ \"/\");\n- servletHandler.addServlet(new ServletHolder(new EventSourceServlet() {\n+ servletHandler.addServlet(\n+ new ServletHolder(\n+ new EventSourceServlet() {\n@Override\n- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {\n+ protected void doGet(\n+ HttpServletRequest req, HttpServletResponse resp)\n+ throws ServletException, IOException {\nif (!checkAuthorization(storeClient, req, resp)) return;\nfinal String subscribedKey = req.getPathInfo().substring(1);\nif (subscribedKey.startsWith(ModelServer.PROTECTED_PREFIX)) {\nresp.setStatus(HttpServletResponse.SC_FORBIDDEN);\nresp.setContentType(\"text/plain\");\n- resp.getWriter().print(\"No permission to access \" + subscribedKey);\n+ resp.getWriter()\n+ .print(\"No permission to access \" + subscribedKey);\n}\nsuper.doGet(req, resp);\n}\n@@ -308,9 +398,11 @@ public class Main {\nfinal String subscribedKey = req.getPathInfo().substring(1);\nreturn new EventSource() {\nprivate Emitter emitter;\n- private IKeyListener listener = new IKeyListener() {\n+ private IKeyListener listener =\n+ new IKeyListener() {\n@Override\n- public void changed(String changedKey, String value) {\n+ public void changed(\n+ String changedKey, String value) {\nif (emitter == null) return;\nif (subscribedKey.equals(changedKey)) {\ntry {\n@@ -336,7 +428,8 @@ public class Main {\n}\n};\n}\n- }), \"/subscribe/*\");\n+ }),\n+ \"/subscribe/*\");\nHandlerList handlerList = new HandlerList();\nhandlerList.addHandler(servletHandler);\n@@ -345,7 +438,9 @@ public class Main {\nserver.start();\nSystem.out.println(\"Server started\");\n- Runtime.getRuntime().addShutdownHook(new Thread() {\n+ Runtime.getRuntime()\n+ .addShutdownHook(\n+ new Thread() {\n@Override\npublic void run() {\ntry {\n@@ -362,7 +457,9 @@ public class Main {\n}\n}\n- private static boolean checkAuthorization(IStoreClient store, HttpServletRequest req, HttpServletResponse resp) throws IOException {\n+ private static boolean checkAuthorization(\n+ IStoreClient store, HttpServletRequest req, HttpServletResponse resp)\n+ throws IOException {\nif (isValidAuthorization(store, req)) {\nreturn true;\n} else {\n@@ -383,7 +480,8 @@ public class Main {\nif (token == null) return false;\n// Used by MPS instances running in the same kubernetes cluster\n- if (sharedSecret != null && sharedSecret.length() > 0 && token.equals(sharedSecret)) return true;\n+ if (sharedSecret != null && sharedSecret.length() > 0 && token.equals(sharedSecret))\n+ return true;\nString expiresStr = store.get(ModelServer.PROTECTED_PREFIX + \"_token_expires_\" + token);\nif (expiresStr == null) return false;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "diff": "package org.modelix.model.server;\n-import org.apache.log4j.Level;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.eclipse.jetty.websocket.api.RemoteEndpoint;\n-import org.json.JSONArray;\n-import org.json.JSONObject;\n-\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.HashMap;\n@@ -35,6 +28,12 @@ import java.util.Map;\nimport java.util.Set;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n+import org.apache.log4j.Level;\n+import org.apache.log4j.LogManager;\n+import org.apache.log4j.Logger;\n+import org.eclipse.jetty.websocket.api.RemoteEndpoint;\n+import org.json.JSONArray;\n+import org.json.JSONObject;\npublic class ModelServer {\nprivate static final Logger LOG = LogManager.getLogger(ModelServer.class);\n@@ -45,7 +44,8 @@ public class ModelServer {\nprivate Map<RemoteEndpoint, Session> sessions = new HashMap<RemoteEndpoint, Session>();\nprivate Map<String, MessageHandler> messageHandlers = new HashMap<String, MessageHandler>();\nprivate Set<String> subscribedKeys = new HashSet<String>();\n- private IKeyListener keyListener = (key, value) -> {\n+ private IKeyListener keyListener =\n+ (key, value) -> {\nif (subscribedKeys.contains(key)) {\nJSONObject notification = new JSONObject();\nnotification.put(\"type\", \"change\");\n@@ -63,11 +63,14 @@ public class ModelServer {\n};\n{\n- messageHandlers.put(\"get\", new MessageHandler() {\n+ messageHandlers.put(\n+ \"get\",\n+ new MessageHandler() {\n@Override\npublic void handle(RemoteEndpoint conn, JSONObject message) {\nString key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n+ if (key.startsWith(PROTECTED_PREFIX))\n+ throw new RuntimeException(\"No permission to access \" + key);\nString value = storeClient.get(key);\nJSONObject reply = new JSONObject();\nreply.put(\"type\", \"get\");\n@@ -76,11 +79,14 @@ public class ModelServer {\nsend(conn, reply.toString());\n}\n});\n- messageHandlers.put(\"getRecursively\", new MessageHandler() {\n+ messageHandlers.put(\n+ \"getRecursively\",\n+ new MessageHandler() {\n@Override\npublic void handle(RemoteEndpoint conn, JSONObject message) {\nString key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n+ if (key.startsWith(PROTECTED_PREFIX))\n+ throw new RuntimeException(\"No permission to access \" + key);\nJSONObject reply = new JSONObject();\nreply.put(\"type\", \"getRecursively\");\nreply.put(\"entries\", collect(key));\n@@ -88,30 +94,39 @@ public class ModelServer {\nsend(conn, reply.toString());\n}\n});\n- messageHandlers.put(\"put\", new MessageHandler() {\n+ messageHandlers.put(\n+ \"put\",\n+ new MessageHandler() {\n@Override\npublic void handle(RemoteEndpoint conn, JSONObject message) {\nString key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n+ if (key.startsWith(PROTECTED_PREFIX))\n+ throw new RuntimeException(\"No permission to access \" + key);\nString value = message.getString(\"value\");\nstoreClient.put(key, value);\n}\n});\n- messageHandlers.put(\"subscribe\", new MessageHandler() {\n+ messageHandlers.put(\n+ \"subscribe\",\n+ new MessageHandler() {\n@Override\npublic void handle(RemoteEndpoint conn, JSONObject message) {\nString key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n+ if (key.startsWith(PROTECTED_PREFIX))\n+ throw new RuntimeException(\"No permission to access \" + key);\nstoreClient.listen(key, keyListener);\nsubscribedKeys.add(key);\nsessions.get(conn).subscribe(key);\n}\n});\n- messageHandlers.put(\"counter\", new MessageHandler() {\n+ messageHandlers.put(\n+ \"counter\",\n+ new MessageHandler() {\n@Override\npublic void handle(RemoteEndpoint conn, JSONObject message) {\nString key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX)) throw new RuntimeException(\"No permission to access \" + key);\n+ if (key.startsWith(PROTECTED_PREFIX))\n+ throw new RuntimeException(\"No permission to access \" + key);\nlong value = storeClient.generateId(key);\nJSONObject reply = new JSONObject();\nreply.put(\"type\", \"counter\");\n@@ -198,8 +213,7 @@ public class ModelServer {\n}\n}\n- public void onStart() {\n- }\n+ public void onStart() {}\npublic void stop() {\ntry {\n@@ -220,5 +234,4 @@ public class ModelServer {\nhandler.handle(conn, message);\n}\n}\n-\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ModelServerServlet.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ModelServerServlet.java", "diff": "@@ -38,11 +38,14 @@ public class ModelServerServlet extends WebSocketServlet {\n@Override\npublic void configure(WebSocketServletFactory factory) {\n- factory.setCreator(new WebSocketCreator() {\n+ factory.setCreator(\n+ new WebSocketCreator() {\n@Override\n- public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {\n+ public Object createWebSocket(\n+ ServletUpgradeRequest req, ServletUpgradeResponse resp) {\nreturn new WebSocketAdapter() {\nprivate RemoteEndpoint connection;\n+\n@Override\npublic void onWebSocketClose(int statusCode, String reason) {\nsuper.onWebSocketClose(statusCode, reason);\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RedisStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RedisStoreClient.java", "diff": "@@ -22,7 +22,6 @@ package org.modelix.model.server;\nimport io.lettuce.core.RedisClient;\nimport io.lettuce.core.api.StatefulRedisConnection;\nimport io.lettuce.core.api.sync.RedisCommands;\n-\nimport java.util.List;\nimport java.util.stream.Collectors;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Session.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Session.java", "diff": "package org.modelix.model.server;\n-import org.eclipse.jetty.websocket.api.RemoteEndpoint;\n-import org.java_websocket.WebSocket;\n-\nimport java.util.HashSet;\nimport java.util.Set;\nimport java.util.concurrent.atomic.AtomicLong;\n+import org.eclipse.jetty.websocket.api.RemoteEndpoint;\npublic class Session {\nprivate static final AtomicLong ID_SEQUENCE = new AtomicLong();\n@@ -37,8 +35,7 @@ public class Session {\nconnection = conn;\n}\n- public void dispose() {\n- }\n+ public void dispose() {}\npublic RemoteEndpoint getConnection() {\nreturn this.connection;\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
formatting the codebase
426,504
17.07.2020 12:38:42
-7,200
a2b142673a57853258512bde094579478ceefa68
reuse sourceCompatibility string in formatting configuration
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -53,7 +53,7 @@ application {\nspotless {\njava {\n- googleJavaFormat('1.8').aosp()\n+ googleJavaFormat(sourceCompatibility.toString()).aosp()\nlicenseHeader '/*\\n' +\n' * Licensed under the Apache License, Version 2.0 (the \"License\");\\n' +\n' * you may not use this file except in compliance with the License.\\n' +\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
reuse sourceCompatibility string in formatting configuration
426,504
17.07.2020 12:51:09
-7,200
73903465e5be4b9efe1dc35d3f2b33f461990574
adding maven publish configuration
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "plugins {\nid \"application\"\nid \"com.diffplug.gradle.spotless\" version \"4.5.1\"\n+ id 'maven-publish'\n}\napply plugin: 'java'\ngroup = 'org.modelix'\n+description = 'Model Server offering access to model storage'\nversion = '1.0-SNAPSHOT'\ndescription = \"modelix model server\"\n@@ -71,3 +73,14 @@ spotless {\n'\\n'\n}\n}\n+\n+publishing {\n+ publications {\n+ modelServer(MavenPublication) {\n+ groupId project.group\n+ version project.version\n+\n+ from components.java\n+ }\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding maven publish configuration
426,496
20.07.2020 11:46:43
-7,200
2fdb2b44032d1dc597b9b0129248bb5c53fe10f6
Remove websocket implementation from the model-server It is not used anymore by the client and was replaced by the REST API.
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "@@ -96,8 +96,6 @@ public class Main {\n}\nServletContextHandler servletHandler = new ServletContextHandler();\n- servletHandler.addServlet(\n- new ServletHolder(new ModelServerServlet(modelServer)), \"/ws\");\nservletHandler.addServlet(\nnew ServletHolder(\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/ModelServer.java", "diff": "package org.modelix.model.server;\n-import java.io.IOException;\nimport java.util.ArrayList;\n-import java.util.HashMap;\nimport java.util.HashSet;\nimport java.util.List;\n-import java.util.Map;\nimport java.util.Set;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n-import org.apache.log4j.Level;\nimport org.apache.log4j.LogManager;\nimport org.apache.log4j.Logger;\n-import org.eclipse.jetty.websocket.api.RemoteEndpoint;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n@@ -37,101 +32,6 @@ public class ModelServer {\npublic static final String PROTECTED_PREFIX = \"$$$\";\nprivate IStoreClient storeClient;\n- private Map<RemoteEndpoint, Session> sessions = new HashMap<RemoteEndpoint, Session>();\n- private Map<String, MessageHandler> messageHandlers = new HashMap<String, MessageHandler>();\n- private Set<String> subscribedKeys = new HashSet<String>();\n- private IKeyListener keyListener =\n- (key, value) -> {\n- if (subscribedKeys.contains(key)) {\n- JSONObject notification = new JSONObject();\n- notification.put(\"type\", \"change\");\n- notification.put(\"key\", key);\n- notification.put(\"value\", value);\n- String notificationStr = notification.toString();\n- for (Session session : sessions.values()) {\n- if (!(session.isSubscribed(key))) {\n- continue;\n- }\n- RemoteEndpoint c = session.getConnection();\n- send(c, notificationStr);\n- }\n- }\n- };\n-\n- {\n- messageHandlers.put(\n- \"get\",\n- new MessageHandler() {\n- @Override\n- public void handle(RemoteEndpoint conn, JSONObject message) {\n- String key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX))\n- throw new RuntimeException(\"No permission to access \" + key);\n- String value = storeClient.get(key);\n- JSONObject reply = new JSONObject();\n- reply.put(\"type\", \"get\");\n- reply.put(\"key\", key);\n- reply.put(\"value\", value);\n- send(conn, reply.toString());\n- }\n- });\n- messageHandlers.put(\n- \"getRecursively\",\n- new MessageHandler() {\n- @Override\n- public void handle(RemoteEndpoint conn, JSONObject message) {\n- String key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX))\n- throw new RuntimeException(\"No permission to access \" + key);\n- JSONObject reply = new JSONObject();\n- reply.put(\"type\", \"getRecursively\");\n- reply.put(\"entries\", collect(key));\n-\n- send(conn, reply.toString());\n- }\n- });\n- messageHandlers.put(\n- \"put\",\n- new MessageHandler() {\n- @Override\n- public void handle(RemoteEndpoint conn, JSONObject message) {\n- String key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX))\n- throw new RuntimeException(\"No permission to access \" + key);\n- String value = message.getString(\"value\");\n- storeClient.put(key, value);\n- }\n- });\n- messageHandlers.put(\n- \"subscribe\",\n- new MessageHandler() {\n- @Override\n- public void handle(RemoteEndpoint conn, JSONObject message) {\n- String key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX))\n- throw new RuntimeException(\"No permission to access \" + key);\n- storeClient.listen(key, keyListener);\n- subscribedKeys.add(key);\n- sessions.get(conn).subscribe(key);\n- }\n- });\n- messageHandlers.put(\n- \"counter\",\n- new MessageHandler() {\n- @Override\n- public void handle(RemoteEndpoint conn, JSONObject message) {\n- String key = message.getString(\"key\");\n- if (key.startsWith(PROTECTED_PREFIX))\n- throw new RuntimeException(\"No permission to access \" + key);\n- long value = storeClient.generateId(key);\n- JSONObject reply = new JSONObject();\n- reply.put(\"type\", \"counter\");\n- reply.put(\"key\", key);\n- reply.put(\"value\", value);\n- send(conn, reply.toString());\n- }\n- });\n- }\npublic ModelServer(IStoreClient storeClient) {\nthis.storeClient = storeClient;\n@@ -172,62 +72,4 @@ public class ModelServer {\nreturn result;\n}\n-\n- public void broadcast(String message) {\n- for (Session session : sessions.values()) {\n- send(session.getConnection(), message);\n- }\n- }\n-\n- public void onOpen(RemoteEndpoint conn) {\n- sessions.put(conn, new Session(conn));\n- }\n-\n- public void onClose(RemoteEndpoint conn, int code, String reason, boolean remote) {\n- sessions.remove(conn).dispose();\n- }\n-\n- public void onMessage(RemoteEndpoint conn, String message) {\n- // System.out.println(sessions.get(conn).getId() + \" R \" + message);\n- processMessage(conn, new JSONObject(message));\n- }\n-\n- private void send(RemoteEndpoint conn, String message) {\n- // System.out.println(sessions.get(conn).getId() + \" S \" + message);\n- try {\n- conn.sendString(message);\n- } catch (IOException ex) {\n- LOG.error(\"Failed to send message: \" + message, ex);\n- }\n- }\n-\n- public void onError(RemoteEndpoint conn, Throwable exception) {\n- System.out.println(\"Error \" + exception.getMessage());\n- exception.printStackTrace();\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"Error \" + conn, exception);\n- }\n- }\n-\n- public void onStart() {}\n-\n- public void stop() {\n- try {\n- for (Session session : sessions.values()) {\n- session.dispose();\n- }\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- }\n- }\n-\n- public void processMessage(RemoteEndpoint conn, JSONObject message) {\n- String type = message.getString(\"type\");\n- MessageHandler handler = messageHandlers.get(type);\n- if (handler != null) {\n- handler.handle(conn, message);\n- }\n- }\n}\n" }, { "change_type": "DELETE", "old_path": "model-server/src/main/java/org/modelix/model/server/ModelServerServlet.java", "new_path": null, "diff": "-/*\n- * Licensed under the Apache License, Version 2.0 (the \"License\");\n- * you may not use this file except in compliance with the License.\n- * You may obtain a copy of the License at\n- *\n- * http://www.apache.org/licenses/LICENSE-2.0\n- *\n- * Unless required by applicable law or agreed to in writing,\n- * software distributed under the License is distributed on an\n- * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n- * KIND, either express or implied. See the License for the\n- * specific language governing permissions and limitations\n- * under the License.\n- */\n-\n-package org.modelix.model.server;\n-\n-import org.eclipse.jetty.websocket.api.RemoteEndpoint;\n-import org.eclipse.jetty.websocket.api.Session;\n-import org.eclipse.jetty.websocket.api.WebSocketAdapter;\n-import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;\n-import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;\n-import org.eclipse.jetty.websocket.servlet.WebSocketCreator;\n-import org.eclipse.jetty.websocket.servlet.WebSocketServlet;\n-import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;\n-\n-public class ModelServerServlet extends WebSocketServlet {\n-\n- private ModelServer modelServer;\n-\n- public ModelServerServlet(ModelServer modelServer) {\n- this.modelServer = modelServer;\n- }\n-\n- @Override\n- public void configure(WebSocketServletFactory factory) {\n- factory.setCreator(\n- new WebSocketCreator() {\n- @Override\n- public Object createWebSocket(\n- ServletUpgradeRequest req, ServletUpgradeResponse resp) {\n- return new WebSocketAdapter() {\n- private RemoteEndpoint connection;\n-\n- @Override\n- public void onWebSocketClose(int statusCode, String reason) {\n- super.onWebSocketClose(statusCode, reason);\n- modelServer.onClose(connection, statusCode, reason, true);\n- }\n-\n- @Override\n- public void onWebSocketConnect(Session sess) {\n- super.onWebSocketConnect(sess);\n- this.connection = sess.getRemote();\n- modelServer.onOpen(sess.getRemote());\n- }\n-\n- @Override\n- public void onWebSocketError(Throwable cause) {\n- super.onWebSocketError(cause);\n- modelServer.onError(connection, cause);\n- }\n-\n- @Override\n- public void onWebSocketText(String message) {\n- super.onWebSocketText(message);\n- modelServer.onMessage(connection, message);\n- }\n- };\n- }\n- });\n- }\n-}\n" }, { "change_type": "DELETE", "old_path": "model-server/src/main/java/org/modelix/model/server/Session.java", "new_path": null, "diff": "-/*\n- * Licensed under the Apache License, Version 2.0 (the \"License\");\n- * you may not use this file except in compliance with the License.\n- * You may obtain a copy of the License at\n- *\n- * http://www.apache.org/licenses/LICENSE-2.0\n- *\n- * Unless required by applicable law or agreed to in writing,\n- * software distributed under the License is distributed on an\n- * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n- * KIND, either express or implied. See the License for the\n- * specific language governing permissions and limitations\n- * under the License.\n- */\n-\n-package org.modelix.model.server;\n-\n-import java.util.HashSet;\n-import java.util.Set;\n-import java.util.concurrent.atomic.AtomicLong;\n-import org.eclipse.jetty.websocket.api.RemoteEndpoint;\n-\n-public class Session {\n- private static final AtomicLong ID_SEQUENCE = new AtomicLong();\n-\n- private long id = ID_SEQUENCE.incrementAndGet();\n- private RemoteEndpoint connection;\n- private Set<String> subscribedKeys = new HashSet<String>();\n-\n- public Session(RemoteEndpoint conn) {\n- connection = conn;\n- }\n-\n- public void dispose() {}\n-\n- public RemoteEndpoint getConnection() {\n- return this.connection;\n- }\n-\n- public boolean isSubscribed(String key) {\n- return subscribedKeys.contains(key);\n- }\n-\n- public void subscribe(String key) {\n- subscribedKeys.add(key);\n- }\n-\n- public void unsubscribe(String key) {\n- subscribedKeys.remove(key);\n- }\n-\n- public long getId() {\n- return id;\n- }\n-}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Remove websocket implementation from the model-server It is not used anymore by the client and was replaced by the REST API.
426,496
21.07.2020 18:10:17
-7,200
ac8b44cee06feab33e2b6703d5e548277ac95801
git4idea jar were not on the classpath during compilation
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.buildhacks/generator/templates/[email protected]", "new_path": "mps/org.modelix.buildhacks/generator/templates/[email protected]", "diff": "<model ref=\"r:b50a408d-f48c-4aa2-b27f-8ef56a3217d6(main@generator)\">\n<persistence version=\"9\" />\n<languages>\n+ <use id=\"798100da-4f0a-421a-b991-71f8c50ce5d2\" name=\"jetbrains.mps.build\" version=\"0\" />\n+ <use id=\"479c7a8c-02f9-43b5-9139-d910cb22f298\" name=\"jetbrains.mps.core.xml\" version=\"0\" />\n<devkit ref=\"a2eb3a43-fcc2-4200-80dc-c60110c4862d(jetbrains.mps.devkit.templates)\" />\n</languages>\n<imports>\n<language id=\"f3061a53-9226-4cc5-a443-f952ceaf5816\" name=\"jetbrains.mps.baseLanguage\">\n<concept id=\"1225271177708\" name=\"jetbrains.mps.baseLanguage.structure.StringType\" flags=\"in\" index=\"17QB3L\" />\n</language>\n+ <language id=\"479c7a8c-02f9-43b5-9139-d910cb22f298\" name=\"jetbrains.mps.core.xml\">\n+ <concept id=\"6666499814681541919\" name=\"jetbrains.mps.core.xml.structure.XmlTextValue\" flags=\"ng\" index=\"2pMdtt\">\n+ <property id=\"6666499814681541920\" name=\"text\" index=\"2pMdty\" />\n+ </concept>\n+ <concept id=\"6666499814681415858\" name=\"jetbrains.mps.core.xml.structure.XmlElement\" flags=\"ng\" index=\"2pNNFK\">\n+ <property id=\"6666499814681415862\" name=\"tagName\" index=\"2pNNFO\" />\n+ <property id=\"6999033275467544021\" name=\"shortEmptyNotation\" index=\"qg3DV\" />\n+ <child id=\"6666499814681415861\" name=\"attributes\" index=\"2pNNFR\" />\n+ </concept>\n+ <concept id=\"6666499814681447923\" name=\"jetbrains.mps.core.xml.structure.XmlAttribute\" flags=\"ng\" index=\"2pNUuL\">\n+ <property id=\"6666499814681447926\" name=\"attrName\" index=\"2pNUuO\" />\n+ <child id=\"6666499814681541918\" name=\"value\" index=\"2pMdts\" />\n+ </concept>\n+ </language>\n<language id=\"b401a680-8325-4110-8fd3-84331ff25bef\" name=\"jetbrains.mps.lang.generator\">\n- <concept id=\"1202776937179\" name=\"jetbrains.mps.lang.generator.structure.AbandonInput_RuleConsequence\" flags=\"lg\" index=\"b5Tf3\" />\n<concept id=\"1095416546421\" name=\"jetbrains.mps.lang.generator.structure.MappingConfiguration\" flags=\"ig\" index=\"bUwia\" />\n+ <concept id=\"1177093525992\" name=\"jetbrains.mps.lang.generator.structure.InlineTemplate_RuleConsequence\" flags=\"lg\" index=\"gft3U\">\n+ <child id=\"1177093586806\" name=\"templateNode\" index=\"gfFT$\" />\n+ </concept>\n<concept id=\"1112730859144\" name=\"jetbrains.mps.lang.generator.structure.TemplateSwitch\" flags=\"ig\" index=\"jVnub\">\n<reference id=\"1112820671508\" name=\"modifiedSwitch\" index=\"phYkn\" />\n<child id=\"1167340453568\" name=\"reductionMappingRule\" index=\"3aUrZf\" />\n<child id=\"1805153994415893199\" name=\"type\" index=\"1N15GL\" />\n</concept>\n</language>\n+ <language id=\"798100da-4f0a-421a-b991-71f8c50ce5d2\" name=\"jetbrains.mps.build\">\n+ <concept id=\"8056730377013322101\" name=\"jetbrains.mps.build.structure.BuildSource_JavaDependencyFileset\" flags=\"ng\" index=\"3di3y\">\n+ <child id=\"7926701909975791137\" name=\"classpath\" index=\"2IxjH2\" />\n+ </concept>\n+ </language>\n<language id=\"7866978e-a0f0-4cc7-81bc-4d213d9375e1\" name=\"jetbrains.mps.lang.smodel\">\n<concept id=\"1138055754698\" name=\"jetbrains.mps.lang.smodel.structure.SNodeType\" flags=\"in\" index=\"3Tqbb2\">\n<reference id=\"1138405853777\" name=\"concept\" index=\"ehGHo\" />\n<ref role=\"phYkn\" to=\"7kwb:4gIjTorxzAe\" resolve=\"switch_ExternalJar\" />\n<node concept=\"3aamgX\" id=\"27MnIraud$j\" role=\"3aUrZf\">\n<property role=\"36QftV\" value=\"true\" />\n- <ref role=\"30HIoZ\" to=\"a4f1:27MnIratvuB\" resolve=\"BuildLayout_Hack\" />\n- <node concept=\"b5Tf3\" id=\"27MnIraud$n\" role=\"1lVwrX\" />\n+ <ref role=\"30HIoZ\" to=\"a4f1:27MnIratvuB\" resolve=\"BuildLayout_Git4IdeaHack\" />\n+ <node concept=\"gft3U\" id=\"6REpCQESYc0\" role=\"1lVwrX\">\n+ <node concept=\"3di3y\" id=\"4gIjToryezf\" role=\"gfFT$\">\n+ <node concept=\"2pNNFK\" id=\"4gIjToryezh\" role=\"2IxjH2\">\n+ <property role=\"2pNNFO\" value=\"fileset\" />\n+ <property role=\"qg3DV\" value=\"true\" />\n+ <node concept=\"2pNUuL\" id=\"4gIjTorylgG\" role=\"2pNNFR\">\n+ <property role=\"2pNUuO\" value=\"dir\" />\n+ <node concept=\"2pMdtt\" id=\"4gIjTorylgH\" role=\"2pMdts\">\n+ <property role=\"2pMdty\" value=\"${mps_home}/plugins/git4idea/lib/\" />\n+ </node>\n+ </node>\n+ <node concept=\"2pNUuL\" id=\"4gIjToryezl\" role=\"2pNNFR\">\n+ <property role=\"2pNUuO\" value=\"includes\" />\n+ <node concept=\"2pMdtt\" id=\"4gIjToryfpu\" role=\"2pMdts\">\n+ <property role=\"2pMdty\" value=\"*.jar\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1N15co\" id=\"27MnIraud$C\" role=\"1s_3oS\">\n<property role=\"TrG5h\" value=\"currentModule\" />\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.buildhacks/org.modelix.buildhacks.mpl", "new_path": "mps/org.modelix.buildhacks/org.modelix.buildhacks.mpl", "diff": "<language slang=\"l:f2801650-65d5-424e-bb1b-463a8781b786:jetbrains.mps.baseLanguage.javadoc\" version=\"2\" />\n<language slang=\"l:760a0a8c-eabb-4521-8bfd-65db761a9ba3:jetbrains.mps.baseLanguage.logging\" version=\"0\" />\n<language slang=\"l:a247e09e-2435-45ba-b8d2-07e93feba96a:jetbrains.mps.baseLanguage.tuples\" version=\"0\" />\n+ <language slang=\"l:798100da-4f0a-421a-b991-71f8c50ce5d2:jetbrains.mps.build\" version=\"0\" />\n+ <language slang=\"l:479c7a8c-02f9-43b5-9139-d910cb22f298:jetbrains.mps.core.xml\" version=\"0\" />\n<language slang=\"l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core\" version=\"2\" />\n<language slang=\"l:b401a680-8325-4110-8fd3-84331ff25bef:jetbrains.mps.lang.generator\" version=\"3\" />\n<language slang=\"l:d7706f63-9be2-479c-a3da-ae92af1e64d5:jetbrains.mps.lang.generator.generationContext\" version=\"2\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
git4idea jar were not on the classpath during compilation
426,496
22.07.2020 09:20:30
-7,200
65fe603121a852f7e1b4e30a9cce436b4969860b
Changes were not painted in the diff view
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.diff/models/org.modelix.ui.diff.mps", "new_path": "mps/org.modelix.ui.diff/models/org.modelix.ui.diff.mps", "diff": "<model ref=\"r:ab9ceea2-f32a-4ea6-be78-3e6c2d4ef84b(org.modelix.ui.diff)\">\n<persistence version=\"9\" />\n<languages>\n+ <use id=\"654422bf-e75f-44dc-936d-188890a746ce\" name=\"de.slisson.mps.reflection\" version=\"0\" />\n<devkit ref=\"fbc25dd2-5da4-483a-8b19-70928e1b62d7(jetbrains.mps.devkit.general-purpose)\" />\n</languages>\n<imports>\n<import index=\"nwfd\" ref=\"fc3c2aa8-0d4b-463f-a774-40d450aa04a0/java:javax.servlet.http(org.modelix.jetty/)\" />\n<import index=\"opgt\" ref=\"fc3c2aa8-0d4b-463f-a774-40d450aa04a0/java:javax.servlet(org.modelix.jetty/)\" />\n<import index=\"exr9\" ref=\"1ed103c3-3aa6-49b7-9c21-6765ee11f224/java:jetbrains.mps.nodeEditor(MPS.Editor/)\" />\n+ <import index=\"lui2\" ref=\"8865b7a8-5271-43d3-884c-6fd1d9cfdd34/java:org.jetbrains.mps.openapi.module(MPS.OpenAPI/)\" implicit=\"true\" />\n<import index=\"fglx\" ref=\"498d89d2-c2e9-11e2-ad49-6cf049e62fe5/java:com.intellij.openapi.fileTypes(MPS.IDEA/)\" implicit=\"true\" />\n</imports>\n<registry>\n+ <language id=\"654422bf-e75f-44dc-936d-188890a746ce\" name=\"de.slisson.mps.reflection\">\n+ <concept id=\"8473566765277240526\" name=\"de.slisson.mps.reflection.structure.ReflectionMethodCall\" flags=\"ng\" index=\"1PvZjq\" />\n+ </language>\n<language id=\"f3061a53-9226-4cc5-a443-f952ceaf5816\" name=\"jetbrains.mps.baseLanguage\">\n<concept id=\"1224071154655\" name=\"jetbrains.mps.baseLanguage.structure.AsExpression\" flags=\"nn\" index=\"0kSF2\">\n<child id=\"1224071154657\" name=\"classifierType\" index=\"0kSFW\" />\n</language>\n<language id=\"fd392034-7849-419d-9071-12563d152375\" name=\"jetbrains.mps.baseLanguage.closures\">\n<concept id=\"1199569711397\" name=\"jetbrains.mps.baseLanguage.closures.structure.ClosureLiteral\" flags=\"nn\" index=\"1bVj0M\">\n+ <property id=\"890797661671409019\" name=\"forceMultiLine\" index=\"3yWfEV\" />\n<child id=\"1199569906740\" name=\"parameter\" index=\"1bW2Oz\" />\n<child id=\"1199569916463\" name=\"body\" index=\"1bW5cS\" />\n</concept>\n</node>\n</node>\n</node>\n+ <node concept=\"3clFbF\" id=\"2XovqnGOcuL\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGOeCZ\" role=\"3clFbG\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGOcuN\" role=\"2Oq$k0\">\n+ <node concept=\"1rXfSq\" id=\"2XovqnGOcuO\" role=\"2Oq$k0\">\n+ <ref role=\"37wK5l\" node=\"2QFzCYK4dwL\" resolve=\"collectComponents\" />\n+ <node concept=\"37vLTw\" id=\"2XovqnGOcuP\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"27MnIr9XYAF\" resolve=\"viewer\" />\n+ </node>\n+ </node>\n+ <node concept=\"UnYns\" id=\"2XovqnGOcuQ\" role=\"2OqNvi\">\n+ <node concept=\"3uibUv\" id=\"2XovqnGOcuR\" role=\"UnYnz\">\n+ <ref role=\"3uigEE\" to=\"exr9:~EditorComponent\" resolve=\"EditorComponent\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"2es0OD\" id=\"2XovqnGOgky\" role=\"2OqNvi\">\n+ <node concept=\"1bVj0M\" id=\"2XovqnGOgk$\" role=\"23t8la\">\n+ <property role=\"3yWfEV\" value=\"true\" />\n+ <node concept=\"3clFbS\" id=\"2XovqnGOgk_\" role=\"1bW5cS\">\n+ <node concept=\"3clFbF\" id=\"2XovqnGOTEm\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGP0YG\" role=\"3clFbG\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGOZlA\" role=\"2Oq$k0\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGOXCW\" role=\"2Oq$k0\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGOV1t\" role=\"2Oq$k0\">\n+ <node concept=\"37vLTw\" id=\"2XovqnGOTEk\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"2XovqnGOgkA\" resolve=\"editor\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnGOWGf\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"exr9:~EditorComponent.getEditorContext()\" resolve=\"getEditorContext\" />\n+ </node>\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnGOYxG\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"exr9:~EditorContext.getRepository()\" resolve=\"getRepository\" />\n+ </node>\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnGP0ar\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"lui2:~SRepository.getModelAccess()\" resolve=\"getModelAccess\" />\n+ </node>\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnGP1YP\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"lui2:~ModelAccess.runReadAction(java.lang.Runnable)\" resolve=\"runReadAction\" />\n+ <node concept=\"1bVj0M\" id=\"2XovqnGP2WP\" role=\"37wK5m\">\n+ <property role=\"3yWfEV\" value=\"true\" />\n+ <node concept=\"3clFbS\" id=\"2XovqnGP2WQ\" role=\"1bW5cS\">\n+ <node concept=\"3clFbF\" id=\"2XovqnGOhMk\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGOlCf\" role=\"3clFbG\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGOj8Z\" role=\"2Oq$k0\">\n+ <node concept=\"37vLTw\" id=\"2XovqnGOhMj\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"2XovqnGOgkA\" resolve=\"editor\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnGOkNG\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"exr9:~EditorComponent.getHighlightManager()\" resolve=\"getHighlightManager\" />\n+ </node>\n+ </node>\n+ <node concept=\"1PvZjq\" id=\"2XovqnGOr0Y\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"exr9:~NodeHighlightManager.refreshMessagesCache()\" resolve=\"refreshMessagesCache\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"Rh6nW\" id=\"2XovqnGOgkA\" role=\"1bW2Oz\">\n+ <property role=\"TrG5h\" value=\"editor\" />\n+ <node concept=\"2jxLKc\" id=\"2XovqnGOgkB\" role=\"1tU5fm\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbH\" id=\"2XovqnGObPB\" role=\"3cqZAp\" />\n<node concept=\"3cpWs8\" id=\"27MnIrafIJb\" role=\"3cqZAp\">\n<node concept=\"3cpWsn\" id=\"27MnIrafIJc\" role=\"3cpWs9\">\n<property role=\"TrG5h\" value=\"componentToPaint\" />\n</node>\n</node>\n</node>\n+ <node concept=\"3clFbH\" id=\"2XovqnGM2Xl\" role=\"3cqZAp\" />\n+ <node concept=\"3clFbJ\" id=\"2XovqnGM7x$\" role=\"3cqZAp\">\n+ <node concept=\"3clFbS\" id=\"2XovqnGM7xA\" role=\"3clFbx\">\n+ <node concept=\"1HWtB8\" id=\"2XovqnGMfDX\" role=\"3cqZAp\">\n+ <node concept=\"Xjq3P\" id=\"2XovqnGMfZF\" role=\"1HWFw0\" />\n+ <node concept=\"3clFbS\" id=\"2XovqnGMfE1\" role=\"1HWHxc\">\n+ <node concept=\"3clFbF\" id=\"2XovqnGMP_J\" role=\"3cqZAp\">\n+ <node concept=\"37vLTI\" id=\"2XovqnGMP_K\" role=\"3clFbG\">\n+ <node concept=\"37vLTw\" id=\"2XovqnGMP_L\" role=\"37vLTJ\">\n+ <ref role=\"3cqZAo\" node=\"27MnIra3QfK\" resolve=\"images\" />\n+ </node>\n+ <node concept=\"10Nm6u\" id=\"2XovqnGNvjf\" role=\"37vLTx\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbF\" id=\"2XovqnGNvRA\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnGNvRB\" role=\"3clFbG\">\n+ <node concept=\"37vLTw\" id=\"2XovqnGNvRC\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"QucyCqZ7qb\" resolve=\"resp\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnGNvRD\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"nwfd:~HttpServletResponse.setStatus(int)\" resolve=\"setStatus\" />\n+ <node concept=\"10M0yZ\" id=\"2XovqnGNvRE\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" to=\"nwfd:~HttpServletResponse.SC_OK\" resolve=\"SC_OK\" />\n+ <ref role=\"1PxDUh\" to=\"nwfd:~HttpServletResponse\" resolve=\"HttpServletResponse\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3cpWs6\" id=\"2XovqnGNwoh\" role=\"3cqZAp\" />\n+ </node>\n+ <node concept=\"17R0WA\" id=\"2XovqnGNso6\" role=\"3clFbw\">\n+ <node concept=\"Xl_RD\" id=\"2XovqnGNuPV\" role=\"3uHU7w\">\n+ <property role=\"Xl_RC\" value=\"/clean\" />\n+ </node>\n+ <node concept=\"37vLTw\" id=\"2XovqnGMarR\" role=\"3uHU7B\">\n+ <ref role=\"3cqZAo\" node=\"27MnIra7wFS\" resolve=\"pathInfo\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbH\" id=\"2XovqnGM31s\" role=\"3cqZAp\" />\n<node concept=\"3clFbJ\" id=\"27MnIra7BzL\" role=\"3cqZAp\">\n<node concept=\"3clFbS\" id=\"27MnIra7BzN\" role=\"3clFbx\">\n<node concept=\"3clFbF\" id=\"QucyCqZ8BW\" role=\"3cqZAp\">\n</node>\n</node>\n</node>\n+ <node concept=\"3cpWs6\" id=\"2XovqnGLybg\" role=\"3cqZAp\" />\n</node>\n<node concept=\"3y3z36\" id=\"27MnIrabWbs\" role=\"3clFbw\">\n<node concept=\"10Nm6u\" id=\"27MnIrabX$$\" role=\"3uHU7w\" />\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.diff/org.modelix.ui.diff.msd", "new_path": "mps/org.modelix.ui.diff/org.modelix.ui.diff.msd", "diff": "<dependency reexport=\"false\">fc3c2aa8-0d4b-463f-a774-40d450aa04a0(org.modelix.jetty)</dependency>\n</dependencies>\n<languageVersions>\n+ <language slang=\"l:654422bf-e75f-44dc-936d-188890a746ce:de.slisson.mps.reflection\" version=\"0\" />\n<language slang=\"l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage\" version=\"11\" />\n<language slang=\"l:443f4c36-fcf5-4eb6-9500-8d06ed259e3e:jetbrains.mps.baseLanguage.classifiers\" version=\"0\" />\n<language slang=\"l:fd392034-7849-419d-9071-12563d152375:jetbrains.mps.baseLanguage.closures\" version=\"0\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Changes were not painted in the diff view
426,496
22.07.2020 17:49:45
-7,200
f0fe4e245e9776f1ecb9d35fec1466406385e9cf
Show list of pull request below the tag/branch list With links to show a diff for them.
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.diff/models/org.modelix.ui.diff.mps", "new_path": "mps/org.modelix.ui.diff/models/org.modelix.ui.diff.mps", "diff": "</node>\n</node>\n</node>\n+ <node concept=\"3clFbH\" id=\"2XovqnH2dvy\" role=\"3cqZAp\" />\n+ <node concept=\"3cpWs8\" id=\"27MnIra36vA\" role=\"3cqZAp\">\n+ <node concept=\"3cpWsn\" id=\"27MnIra36vB\" role=\"3cpWs9\">\n+ <property role=\"TrG5h\" value=\"vcsManager\" />\n+ <node concept=\"3uibUv\" id=\"27MnIra36vC\" role=\"1tU5fm\">\n+ <ref role=\"3uigEE\" to=\"tkms:~VcsRepositoryManager\" resolve=\"VcsRepositoryManager\" />\n+ </node>\n+ <node concept=\"2YIFZM\" id=\"27MnIra36vD\" role=\"33vP2m\">\n+ <ref role=\"37wK5l\" to=\"tkms:~VcsRepositoryManager.getInstance(com.intellij.openapi.project.Project)\" resolve=\"getInstance\" />\n+ <ref role=\"1Pybhc\" to=\"tkms:~VcsRepositoryManager\" resolve=\"VcsRepositoryManager\" />\n+ <node concept=\"37vLTw\" id=\"27MnIra36vE\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"4kPMkltJPHc\" resolve=\"project\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbJ\" id=\"2XovqnH2g2E\" role=\"3cqZAp\">\n+ <node concept=\"3clFbS\" id=\"2XovqnH2g2G\" role=\"3clFbx\">\n+ <node concept=\"3clFbF\" id=\"27MnIra36vF\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"27MnIra36vG\" role=\"3clFbG\">\n+ <node concept=\"37vLTw\" id=\"27MnIra36vH\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"27MnIra36vB\" resolve=\"vcsManager\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"27MnIra36vI\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"tkms:~VcsRepositoryManager.addExternalRepository(com.intellij.openapi.vfs.VirtualFile,com.intellij.dvcs.repo.Repository)\" resolve=\"addExternalRepository\" />\n+ <node concept=\"37vLTw\" id=\"27MnIra36vJ\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"1RZ$z1qew1T\" resolve=\"repoRoot\" />\n+ </node>\n+ <node concept=\"2YIFZM\" id=\"27MnIra36vK\" role=\"37wK5m\">\n+ <ref role=\"37wK5l\" to=\"5mlj:~GitRepositoryImpl.createInstance(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.project.Project,com.intellij.openapi.Disposable,boolean)\" resolve=\"createInstance\" />\n+ <ref role=\"1Pybhc\" to=\"5mlj:~GitRepositoryImpl\" resolve=\"GitRepositoryImpl\" />\n+ <node concept=\"37vLTw\" id=\"27MnIra36vL\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"1RZ$z1qew1T\" resolve=\"repoRoot\" />\n+ </node>\n+ <node concept=\"37vLTw\" id=\"27MnIra36vM\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"4kPMkltJPHc\" resolve=\"project\" />\n+ </node>\n+ <node concept=\"37vLTw\" id=\"27MnIra36vN\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"27MnIra36vB\" resolve=\"vcsManager\" />\n+ </node>\n+ <node concept=\"3clFbT\" id=\"27MnIra36vO\" role=\"37wK5m\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbC\" id=\"2XovqnH2ghS\" role=\"3clFbw\">\n+ <node concept=\"10Nm6u\" id=\"2XovqnH2gpT\" role=\"3uHU7w\" />\n+ <node concept=\"2OqwBi\" id=\"2XovqnH2ffx\" role=\"3uHU7B\">\n+ <node concept=\"37vLTw\" id=\"2XovqnH2eNx\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"27MnIra36vB\" resolve=\"vcsManager\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnH2fv8\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"tkms:~VcsRepositoryManager.getRepositoryForRoot(com.intellij.openapi.vfs.VirtualFile)\" resolve=\"getRepositoryForRoot\" />\n+ <node concept=\"37vLTw\" id=\"2XovqnH2fJt\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"1RZ$z1qew1T\" resolve=\"repoRoot\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"3y3z36\" id=\"1RZ$z1qfYFV\" role=\"3clFbw\">\n<node concept=\"10Nm6u\" id=\"1RZ$z1qfZ6z\" role=\"3uHU7w\" />\n</node>\n</node>\n<node concept=\"3clFbS\" id=\"27MnIra36v_\" role=\"1zxBo7\">\n- <node concept=\"3cpWs8\" id=\"27MnIra36vA\" role=\"3cqZAp\">\n- <node concept=\"3cpWsn\" id=\"27MnIra36vB\" role=\"3cpWs9\">\n- <property role=\"TrG5h\" value=\"vcsManager\" />\n- <node concept=\"3uibUv\" id=\"27MnIra36vC\" role=\"1tU5fm\">\n- <ref role=\"3uigEE\" to=\"tkms:~VcsRepositoryManager\" resolve=\"VcsRepositoryManager\" />\n- </node>\n- <node concept=\"2YIFZM\" id=\"27MnIra36vD\" role=\"33vP2m\">\n- <ref role=\"37wK5l\" to=\"tkms:~VcsRepositoryManager.getInstance(com.intellij.openapi.project.Project)\" resolve=\"getInstance\" />\n- <ref role=\"1Pybhc\" to=\"tkms:~VcsRepositoryManager\" resolve=\"VcsRepositoryManager\" />\n- <node concept=\"37vLTw\" id=\"27MnIra36vE\" role=\"37wK5m\">\n- <ref role=\"3cqZAo\" node=\"4kPMkltJPHc\" resolve=\"project\" />\n- </node>\n- </node>\n- </node>\n- </node>\n- <node concept=\"3clFbF\" id=\"27MnIra36vF\" role=\"3cqZAp\">\n- <node concept=\"2OqwBi\" id=\"27MnIra36vG\" role=\"3clFbG\">\n- <node concept=\"37vLTw\" id=\"27MnIra36vH\" role=\"2Oq$k0\">\n- <ref role=\"3cqZAo\" node=\"27MnIra36vB\" resolve=\"vcsManager\" />\n- </node>\n- <node concept=\"liA8E\" id=\"27MnIra36vI\" role=\"2OqNvi\">\n- <ref role=\"37wK5l\" to=\"tkms:~VcsRepositoryManager.addExternalRepository(com.intellij.openapi.vfs.VirtualFile,com.intellij.dvcs.repo.Repository)\" resolve=\"addExternalRepository\" />\n- <node concept=\"37vLTw\" id=\"27MnIra36vJ\" role=\"37wK5m\">\n- <ref role=\"3cqZAo\" node=\"1RZ$z1qeo2A\" resolve=\"repoRoot\" />\n- </node>\n- <node concept=\"2YIFZM\" id=\"27MnIra36vK\" role=\"37wK5m\">\n- <ref role=\"1Pybhc\" to=\"5mlj:~GitRepositoryImpl\" resolve=\"GitRepositoryImpl\" />\n- <ref role=\"37wK5l\" to=\"5mlj:~GitRepositoryImpl.createInstance(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.project.Project,com.intellij.openapi.Disposable,boolean)\" resolve=\"createInstance\" />\n- <node concept=\"37vLTw\" id=\"27MnIra36vL\" role=\"37wK5m\">\n- <ref role=\"3cqZAo\" node=\"1RZ$z1qeo2A\" resolve=\"repoRoot\" />\n- </node>\n- <node concept=\"37vLTw\" id=\"27MnIra36vM\" role=\"37wK5m\">\n- <ref role=\"3cqZAo\" node=\"4kPMkltJPHc\" resolve=\"project\" />\n- </node>\n- <node concept=\"37vLTw\" id=\"27MnIra36vN\" role=\"37wK5m\">\n- <ref role=\"3cqZAo\" node=\"27MnIra36vB\" resolve=\"vcsManager\" />\n- </node>\n- <node concept=\"3clFbT\" id=\"27MnIra36vO\" role=\"37wK5m\" />\n- </node>\n- </node>\n- </node>\n- </node>\n<node concept=\"3cpWs8\" id=\"27MnIra36vP\" role=\"3cqZAp\">\n<node concept=\"3cpWsn\" id=\"27MnIra36vQ\" role=\"3cpWs9\">\n<property role=\"TrG5h\" value=\"history\" />\n</node>\n</node>\n</node>\n+ <node concept=\"3clFbJ\" id=\"2XovqnH1_iL\" role=\"3cqZAp\">\n+ <node concept=\"3clFbS\" id=\"2XovqnH1_iN\" role=\"3clFbx\">\n+ <node concept=\"RRSsy\" id=\"2XovqnH1DRa\" role=\"3cqZAp\">\n+ <property role=\"RRSoG\" value=\"gZ5fh_4/error\" />\n+ <node concept=\"Xl_RD\" id=\"2XovqnH1DRc\" role=\"RRSoy\">\n+ <property role=\"Xl_RC\" value=\"Diff failed\" />\n+ </node>\n+ <node concept=\"2OqwBi\" id=\"2XovqnH1CO9\" role=\"RRSow\">\n+ <node concept=\"1eOMI4\" id=\"2XovqnH1BTN\" role=\"2Oq$k0\">\n+ <node concept=\"10QFUN\" id=\"2XovqnH1BTK\" role=\"1eOMHV\">\n+ <node concept=\"3uibUv\" id=\"2XovqnH1BTP\" role=\"10QFUM\">\n+ <ref role=\"3uigEE\" to=\"phib:~ErrorDiffRequest\" resolve=\"ErrorDiffRequest\" />\n+ </node>\n+ <node concept=\"37vLTw\" id=\"2XovqnH1CmL\" role=\"10QFUP\">\n+ <ref role=\"3cqZAo\" node=\"27MnIr9XYAk\" resolve=\"diffRequest\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnH1Dfo\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"phib:~ErrorDiffRequest.getException()\" resolve=\"getException\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbF\" id=\"2XovqnH1FuO\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnH1G7r\" role=\"3clFbG\">\n+ <node concept=\"37vLTw\" id=\"2XovqnH1FuM\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"27MnIr9Yojp\" resolve=\"listFuture\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnH1H1u\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"ixe9:~FutureResult.setException(java.lang.Throwable)\" resolve=\"setException\" />\n+ <node concept=\"2OqwBi\" id=\"2XovqnH1Hhj\" role=\"37wK5m\">\n+ <node concept=\"1eOMI4\" id=\"2XovqnH1Hhk\" role=\"2Oq$k0\">\n+ <node concept=\"10QFUN\" id=\"2XovqnH1Hhl\" role=\"1eOMHV\">\n+ <node concept=\"3uibUv\" id=\"2XovqnH1Hhm\" role=\"10QFUM\">\n+ <ref role=\"3uigEE\" to=\"phib:~ErrorDiffRequest\" resolve=\"ErrorDiffRequest\" />\n+ </node>\n+ <node concept=\"37vLTw\" id=\"2XovqnH1Hhn\" role=\"10QFUP\">\n+ <ref role=\"3cqZAo\" node=\"27MnIr9XYAk\" resolve=\"diffRequest\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnH1Hho\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"phib:~ErrorDiffRequest.getException()\" resolve=\"getException\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"2ZW3vV\" id=\"2XovqnH1Bax\" role=\"3clFbw\">\n+ <node concept=\"3uibUv\" id=\"2XovqnH1Bwn\" role=\"2ZW6by\">\n+ <ref role=\"3uigEE\" to=\"phib:~ErrorDiffRequest\" resolve=\"ErrorDiffRequest\" />\n+ </node>\n+ <node concept=\"37vLTw\" id=\"2XovqnH1ACZ\" role=\"2ZW6bz\">\n+ <ref role=\"3cqZAo\" node=\"27MnIr9XYAk\" resolve=\"diffRequest\" />\n+ </node>\n+ </node>\n+ </node>\n<node concept=\"3clFbF\" id=\"27MnIr9XYAs\" role=\"3cqZAp\">\n<node concept=\"2YIFZM\" id=\"27MnIr9XYAt\" role=\"3clFbG\">\n<ref role=\"37wK5l\" to=\"3a50:~ThreadUtils.runInUIThreadNoWait(java.lang.Runnable)\" resolve=\"runInUIThreadNoWait\" />\n</node>\n</node>\n</node>\n- <node concept=\"3clFbH\" id=\"2XovqnGGgho\" role=\"3cqZAp\" />\n+ <node concept=\"3clFbJ\" id=\"2XovqnH2hri\" role=\"3cqZAp\">\n+ <node concept=\"3clFbS\" id=\"2XovqnH2hrk\" role=\"3clFbx\">\n+ <node concept=\"3clFbF\" id=\"2XovqnH2rKT\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"2XovqnH2sXF\" role=\"3clFbG\">\n+ <node concept=\"37vLTw\" id=\"2XovqnH2rKS\" role=\"2Oq$k0\">\n+ <ref role=\"3cqZAo\" node=\"27MnIr9Yojp\" resolve=\"listFuture\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"2XovqnH2tMm\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"ixe9:~FutureResult.set(java.lang.Object)\" resolve=\"set\" />\n+ <node concept=\"2ShNRf\" id=\"2XovqnH2vaY\" role=\"37wK5m\">\n+ <node concept=\"Tc6Ow\" id=\"2XovqnH2xr1\" role=\"2ShVmc\">\n+ <node concept=\"3uibUv\" id=\"2XovqnH2$vu\" role=\"HW$YZ\">\n+ <ref role=\"3uigEE\" to=\"5zyv:~Future\" resolve=\"Future\" />\n+ <node concept=\"3uibUv\" id=\"2XovqnH2B0X\" role=\"11_B2D\">\n+ <ref role=\"3uigEE\" node=\"27MnIr9Ypso\" resolve=\"DiffImage\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbC\" id=\"2XovqnH2KvM\" role=\"3clFbw\">\n+ <node concept=\"37vLTw\" id=\"2XovqnH2iKU\" role=\"3uHU7B\">\n+ <ref role=\"3cqZAo\" node=\"27MnIr9XYAQ\" resolve=\"diffTree\" />\n+ </node>\n+ <node concept=\"10Nm6u\" id=\"2XovqnH2l2s\" role=\"3uHU7w\" />\n+ </node>\n+ <node concept=\"9aQIb\" id=\"2XovqnH2qu3\" role=\"9aQIa\">\n+ <node concept=\"3clFbS\" id=\"2XovqnH2qu4\" role=\"9aQI4\">\n<node concept=\"3cpWs8\" id=\"2XovqnGGSkd\" role=\"3cqZAp\">\n<node concept=\"3cpWsn\" id=\"2XovqnGGSke\" role=\"3cpWs9\">\n<property role=\"TrG5h\" value=\"rows\" />\n</node>\n</node>\n</node>\n+ </node>\n+ </node>\n+ </node>\n<node concept=\"1wplmZ\" id=\"27MnIr9YUfh\" role=\"1zxBo6\">\n<node concept=\"3clFbS\" id=\"27MnIr9YUfi\" role=\"1wplMD\">\n<node concept=\"3clFbF\" id=\"27MnIr9YRiB\" role=\"3cqZAp\">\n<ref role=\"3uigEE\" to=\"guwi:~IOException\" resolve=\"IOException\" />\n</node>\n<node concept=\"3clFbS\" id=\"QucyCqZ7qf\" role=\"3clF47\">\n+ <node concept=\"3J1_TO\" id=\"2XovqnH4boc\" role=\"3cqZAp\">\n+ <node concept=\"3uVAMA\" id=\"2XovqnH4e7n\" role=\"1zxBo5\">\n+ <node concept=\"XOnhg\" id=\"2XovqnH4e7o\" role=\"1zc67B\">\n+ <property role=\"TrG5h\" value=\"ex\" />\n+ <node concept=\"nSUau\" id=\"2XovqnH4e7p\" role=\"1tU5fm\">\n+ <node concept=\"3uibUv\" id=\"2XovqnH4g0J\" role=\"nSUat\">\n+ <ref role=\"3uigEE\" to=\"wyt6:~Exception\" resolve=\"Exception\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbS\" id=\"2XovqnH4e7q\" role=\"1zc67A\">\n+ <node concept=\"RRSsy\" id=\"2XovqnH4sW2\" role=\"3cqZAp\">\n+ <property role=\"RRSoG\" value=\"gZ5fh_4/error\" />\n+ <node concept=\"Xl_RD\" id=\"2XovqnH4sW4\" role=\"RRSoy\" />\n+ <node concept=\"37vLTw\" id=\"2XovqnH4vFz\" role=\"RRSow\">\n+ <ref role=\"3cqZAo\" node=\"2XovqnH4e7o\" resolve=\"ex\" />\n+ </node>\n+ </node>\n+ <node concept=\"YS8fn\" id=\"2XovqnH4z0u\" role=\"3cqZAp\">\n+ <node concept=\"2ShNRf\" id=\"2XovqnH4zkz\" role=\"YScLw\">\n+ <node concept=\"1pGfFk\" id=\"2XovqnH4BMW\" role=\"2ShVmc\">\n+ <ref role=\"37wK5l\" to=\"wyt6:~RuntimeException.&lt;init&gt;(java.lang.Throwable)\" resolve=\"RuntimeException\" />\n+ <node concept=\"37vLTw\" id=\"2XovqnH4C$u\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"2XovqnH4e7o\" resolve=\"ex\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"3clFbS\" id=\"2XovqnH4boe\" role=\"1zxBo7\">\n<node concept=\"3cpWs8\" id=\"27MnIra7wFR\" role=\"3cqZAp\">\n<node concept=\"3cpWsn\" id=\"27MnIra7wFS\" role=\"3cpWs9\">\n<property role=\"TrG5h\" value=\"pathInfo\" />\n</node>\n</node>\n</node>\n- <node concept=\"3clFbF\" id=\"2XovqnGFlEu\" role=\"3cqZAp\">\n- <node concept=\"2OqwBi\" id=\"2XovqnGFnaj\" role=\"3clFbG\">\n- <node concept=\"37vLTw\" id=\"2XovqnGFlEs\" role=\"2Oq$k0\">\n- <ref role=\"3cqZAo\" node=\"27MnIra4Hyb\" resolve=\"writer\" />\n- </node>\n- <node concept=\"liA8E\" id=\"2XovqnGFnuZ\" role=\"2OqNvi\">\n- <ref role=\"37wK5l\" to=\"guwi:~PrintWriter.flush()\" resolve=\"flush\" />\n- </node>\n- </node>\n- </node>\n</node>\n</node>\n<node concept=\"3clFbF\" id=\"27MnIra5ycA\" role=\"3cqZAp\">\n</node>\n</node>\n</node>\n+ </node>\n+ </node>\n<node concept=\"2AHcQZ\" id=\"QucyCqZ7qg\" role=\"2AJF6D\">\n<ref role=\"2AI5Lk\" to=\"wyt6:~Override\" resolve=\"Override\" />\n</node>\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/build.gradle", "new_path": "ui-proxy/build.gradle", "diff": "@@ -19,6 +19,7 @@ repositories {\ndependencies {\ntestCompile group: 'junit', name: 'junit', version: '4.12'\ncompile 'io.kubernetes:client-java:8.0.2'\n+ compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.30'\ncompile group: 'log4j', name: 'log4j', version: '1.2.17'\ncompile group: 'commons-codec', name: 'commons-codec', version: '1.14'\ncompile group: 'commons-io', name: 'commons-io', version: '2.6'\n@@ -33,6 +34,7 @@ dependencies {\ncompile group: 'org.eclipse.jetty.websocket', name: 'websocket-server', version: jettyVersion\ncompile group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.8.0.202006091008-r'\n+ compile group: 'org.kohsuke', name: 'github-api', version: '1.115'\n}\ntask copyRuntimeLibs(type: Copy) {\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "package org.modelix.uiproxy;\n-import io.kubernetes.client.PodLogs;\nimport io.kubernetes.client.custom.Quantity;\nimport io.kubernetes.client.openapi.ApiException;\nimport io.kubernetes.client.openapi.Configuration;\n@@ -17,7 +16,6 @@ import io.kubernetes.client.openapi.models.V1ServiceList;\nimport io.kubernetes.client.util.ClientBuilder;\nimport io.kubernetes.client.util.Yaml;\nimport org.apache.commons.collections4.map.HashedMap;\n-import org.apache.commons.io.IOUtils;\nimport org.apache.commons.lang.StringEscapeUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jetty.server.Request;\n@@ -25,18 +23,20 @@ import org.eclipse.jetty.server.handler.AbstractHandler;\nimport org.eclipse.jgit.api.Git;\nimport org.eclipse.jgit.api.errors.GitAPIException;\nimport org.eclipse.jgit.lib.Ref;\n+import org.kohsuke.github.GHIssueState;\n+import org.kohsuke.github.GHPullRequest;\n+import org.kohsuke.github.GHRepository;\n+import org.kohsuke.github.GitHub;\n+import org.kohsuke.github.GitHubBuilder;\nimport javax.servlet.ServletException;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\nimport java.io.IOException;\n-import java.io.InputStream;\n-import java.nio.charset.StandardCharsets;\nimport java.util.Collection;\nimport java.util.Collections;\n+import java.util.List;\nimport java.util.Map;\n-import java.util.Timer;\n-import java.util.concurrent.Executors;\nimport java.util.function.Supplier;\npublic class DeploymentManagingHandler extends AbstractHandler {\n@@ -104,7 +104,8 @@ public class DeploymentManagingHandler extends AbstractHandler {\n.append(\"<html>\")\n.append(\"<head>\")\n.append(\"</head>\")\n- .append(\"<body>\");\n+ .append(\"<body>\")\n+ .append(\"<h1>Tags and Branches</h1>\");\nfor (Ref ref : refs) {\nresponse.getWriter()\n@@ -115,6 +116,40 @@ public class DeploymentManagingHandler extends AbstractHandler {\n.append(\"</a></div>\");\n}\n+ response.getWriter().append(\"<h1>Pull Requests</h1>\");\n+ try {\n+ GitHub github = new GitHubBuilder().build();\n+ GHRepository ghRepo = github.getRepository(redirectedURL.getGithubRepositoryName());\n+ List<GHPullRequest> pullRequests = ghRepo.getPullRequests(GHIssueState.ALL);\n+ for (GHPullRequest pullRequest : pullRequests) {\n+ boolean sameRepo = pullRequest.getHead().getRepository().getFullName().equals(\n+ pullRequest.getBase().getRepository().getFullName());\n+ response.getWriter()\n+ .append(\"<div>\");\n+ if (sameRepo) response.getWriter()\n+ .append(\"<a href=\\\"\")\n+ .append(\"commit/\")\n+ .append(pullRequest.getHead().getSha())\n+ .append(\"/diff/\")\n+ .append(pullRequest.getBase().getSha())\n+ .append(\"/\")\n+ .append(pullRequest.getHead().getSha())\n+ .append(\"/\")\n+ .append(\"\\\">\");\n+ response.getWriter()\n+ .append(\"#\")\n+ .append(Integer.toString(pullRequest.getNumber()))\n+ .append(\" - \")\n+ .append(StringEscapeUtils.escapeHtml(pullRequest.getTitle()));\n+ if (sameRepo) response.getWriter()\n+ .append(\"</a>\");\n+ response.getWriter()\n+ .append(\"</div>\");\n+ }\n+ } catch (Exception ex) {\n+ response.getWriter().append(\"<div>\").append(ex.getMessage()).append(\"</div\");\n+ }\n+\nresponse.getWriter()\n.append(\"</body>\")\n.append(\"</html>\");\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/RedirectedURL.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/RedirectedURL.java", "diff": "@@ -19,6 +19,7 @@ public class RedirectedURL {\nif (!parts.get(0).equals(\"github\")) return null;\nString repositoryUrl = \"https://github.com/\" + parts.get(1) + \"/\" + parts.get(2) + \".git\";\n+ String githubRepositoryName = parts.get(1) + \"/\" + parts.get(2);\nparts = parts.subList(3, parts.size());\nString commitId = null;\n@@ -35,18 +36,21 @@ public class RedirectedURL {\nreturn new RedirectedURL(\nremainingPath,\nrepositoryUrl,\n- commitId\n+ commitId,\n+ githubRepositoryName\n);\n}\nprivate String remainingPath;\nprivate String repositoryUrl;\nprivate String commitId;\n+ private String githubRepositoryName;\n- public RedirectedURL(String remainingPath, String repositoryUrl, String commitId) {\n+ public RedirectedURL(String remainingPath, String repositoryUrl, String commitId, String githubRepositoryName) {\nthis.remainingPath = remainingPath;\nthis.repositoryUrl = repositoryUrl;\nthis.commitId = commitId;\n+ this.githubRepositoryName = githubRepositoryName;\n}\npublic String getRemainingPath() {\n@@ -61,6 +65,10 @@ public class RedirectedURL {\nreturn commitId;\n}\n+ public String getGithubRepositoryName() {\n+ return githubRepositoryName;\n+ }\n+\npublic String getDeploymentName() {\nif (getCommitId() == null) throw new RuntimeException(\"No commit ID provided\");\nreturn DEPLOYMENT_PREFIX + DigestUtils.sha1Hex(getRepositoryUrl() + \"@\" + commitId);\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Show list of pull request below the tag/branch list With links to show a diff for them.
426,496
22.07.2020 18:28:56
-7,200
f214839733449e97790df33796c4e41861311c96
Use the same MPS instance for all diffs The head version of a pull request was checked out before. This is not necessary for rendering the diff. The checked out version is not relevant, because a diff can be shown between any two versions.
[ { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "@@ -8,6 +8,7 @@ import io.kubernetes.client.openapi.apis.CoreV1Api;\nimport io.kubernetes.client.openapi.models.V1Deployment;\nimport io.kubernetes.client.openapi.models.V1DeploymentBuilder;\nimport io.kubernetes.client.openapi.models.V1DeploymentList;\n+import io.kubernetes.client.openapi.models.V1EnvVar;\nimport io.kubernetes.client.openapi.models.V1Pod;\nimport io.kubernetes.client.openapi.models.V1PodList;\nimport io.kubernetes.client.openapi.models.V1Service;\n@@ -33,6 +34,7 @@ import javax.servlet.ServletException;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\nimport java.io.IOException;\n+import java.util.Arrays;\nimport java.util.Collection;\nimport java.util.Collections;\nimport java.util.List;\n@@ -88,7 +90,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\nreturn;\n}\n- if (redirectedURL.getCommitId() == null) {\n+ if (\"/\".equals(redirectedURL.getRemainingPath())) {\nCollection<Ref> refs = null;\ntry {\nrefs = Git.lsRemoteRepository()\n@@ -126,23 +128,27 @@ public class DeploymentManagingHandler extends AbstractHandler {\npullRequest.getBase().getRepository().getFullName());\nresponse.getWriter()\n.append(\"<div>\");\n- if (sameRepo) response.getWriter()\n- .append(\"<a href=\\\"\")\n+ response.getWriter()\n+ .append(\"#\")\n+ .append(Integer.toString(pullRequest.getNumber()))\n+ .append(\" - \")\n+ .append(StringEscapeUtils.escapeHtml(pullRequest.getTitle()));\n+ if (sameRepo) {\n+ response.getWriter()\n+ .append(\" (<a href=\\\"\")\n.append(\"commit/\")\n.append(pullRequest.getHead().getSha())\n- .append(\"/diff/\")\n+ .append(\"/\")\n+ .append(\"\\\">Open Version</a>)\")\n+ .append(\"\")\n+ .append(\" (<a href=\\\"\")\n+ .append(\"diff/\")\n.append(pullRequest.getBase().getSha())\n.append(\"/\")\n.append(pullRequest.getHead().getSha())\n.append(\"/\")\n- .append(\"\\\">\");\n- response.getWriter()\n- .append(\"#\")\n- .append(Integer.toString(pullRequest.getNumber()))\n- .append(\" - \")\n- .append(StringEscapeUtils.escapeHtml(pullRequest.getTitle()));\n- if (sameRepo) response.getWriter()\n- .append(\"</a>\");\n+ .append(\"\\\">Show Diff</a>)\");\n+ }\nresponse.getWriter()\n.append(\"</div>\");\n}\n@@ -318,6 +324,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\n.withName(\"GIT_COMMIT_ID\")\n.withValue(gitRepoUrl.getCommitId())\n.endEnv()\n+ .removeMatchingFromEnv(e -> e.getValue() == null)\n.addNewPort()\n.withContainerPort(33333)\n.endPort()\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/RedirectedURL.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/RedirectedURL.java", "diff": "@@ -70,7 +70,6 @@ public class RedirectedURL {\n}\npublic String getDeploymentName() {\n- if (getCommitId() == null) throw new RuntimeException(\"No commit ID provided\");\nreturn DEPLOYMENT_PREFIX + DigestUtils.sha1Hex(getRepositoryUrl() + \"@\" + commitId);\n}\n" }, { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/resources/log4j.xml", "new_path": "ui-proxy/src/main/resources/log4j.xml", "diff": "</layout>\n</appender>\n+ <category name=\"org.modelix\" additivity=\"true\">\n+ <priority value=\"DEBUG\"/>\n+ <appender-ref ref=\"console\"/>\n+ </category>\n+\n<root>\n- <level value=\"DEBUG\" />\n+ <level value=\"INFO\" />\n<appender-ref ref=\"console\" />\n</root>\n" }, { "change_type": "MODIFY", "old_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "new_path": "ui-server/src/main/java/org/modelix/ui/server/Main.java", "diff": "@@ -34,9 +34,9 @@ public class Main {\nGit git = Git.cloneRepository()\n.setURI(gitRepoUri)\n.setDirectory(gitRepoDir)\n- .setNoCheckout(gitCommitId != null)\n+ .setNoCheckout(gitCommitId != null && gitCommitId.length() > 0)\n.call();\n- if (gitCommitId != null) {\n+ if (gitCommitId != null && gitCommitId.length() > 0) {\nSystem.out.println(\"Checkout \" + gitCommitId);\ngit.checkout().setName(gitCommitId).call();\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Use the same MPS instance for all diffs The head version of a pull request was checked out before. This is not necessary for rendering the diff. The checked out version is not relevant, because a diff can be shown between any two versions.
426,496
28.07.2020 12:45:19
-7,200
d974acb2347c652ab2b3a60fad9e9158256b1eb8
Browsing a version didn't work The path /commit/[commitId]/ showed the page with the tags/branches and PRs.
[ { "change_type": "MODIFY", "old_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "new_path": "ui-proxy/src/main/java/org/modelix/uiproxy/DeploymentManagingHandler.java", "diff": "@@ -90,7 +90,7 @@ public class DeploymentManagingHandler extends AbstractHandler {\nreturn;\n}\n- if (\"/\".equals(redirectedURL.getRemainingPath())) {\n+ if (\"/\".equals(redirectedURL.getRemainingPath()) && redirectedURL.getCommitId() == null) {\nCollection<Ref> refs = null;\ntry {\nrefs = Git.lsRemoteRepository()\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Browsing a version didn't work The path /commit/[commitId]/ showed the page with the tags/branches and PRs.
426,496
30.07.2020 12:23:16
-7,200
495c60ebc14f6c07c95f1e971c277ffcd8196e53
Copied tests from MPS
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.java", "diff": "@@ -75,7 +75,12 @@ public class BulkQuery implements IBulkQuery {\ndeserializers.put(request._1(), request._2());\n}\n- final Map<String, Object> entries = executeBulkQuery(currentRequests.stream().map(Tuple3::_1).distinct()::iterator, deserializers);\n+ final Map<String, Object> entries = executeBulkQuery(\n+ currentRequests.stream()\n+ .map(Tuple3::_1)\n+ .distinct()\n+ .collect(Collectors.toList()),\n+ deserializers);\nfor (Tuple3<String, Function<String, ?>, Consumer<Object>> request : currentRequests) {\nrequest._3().accept(entries.get(request._1()));\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/test/java/org/modelix/model/Hamt_Test.java", "diff": "+package org.modelix.model;\n+\n+import org.junit.Assert;\n+import org.junit.Test;\n+import org.modelix.model.lazy.CLHamtInternal;\n+import org.modelix.model.lazy.CLHamtNode;\n+import org.modelix.model.lazy.ObjectStoreCache;\n+import org.modelix.model.persistent.MapBaseStore;\n+\n+import java.util.ArrayList;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Random;\n+\n+public class Hamt_Test {\n+ @Test\n+ public void test_random() {\n+ Random rand = new Random(1);\n+\n+ Map<Long, String> expectedMap = new HashMap<>();\n+ MapBaseStore store = new MapBaseStore();\n+ ObjectStoreCache storeCache = new ObjectStoreCache(store);\n+ CLHamtNode hamt = new CLHamtInternal(storeCache);\n+\n+ for (int i = 0; i < 10000; i++) {\n+ if (expectedMap.isEmpty() || rand.nextBoolean()) {\n+ // add entry\n+ long key = rand.nextInt(1000);\n+ String value = Long.toString(rand.nextLong());\n+ hamt = hamt.put(key, value);\n+ expectedMap.put(key, value);\n+\n+ } else {\n+ List<Long> keys = new ArrayList<>(expectedMap.keySet());\n+ long key = keys.get(rand.nextInt(keys.size()));\n+ if (rand.nextBoolean()) {\n+ // remove entry\n+ hamt = hamt.remove(key);\n+ expectedMap.remove(key);\n+ } else {\n+ // replace entry\n+ String value = Long.toString(rand.nextLong());\n+ hamt = hamt.put(key, value);\n+ expectedMap.put(key, value);\n+ }\n+ }\n+\n+ storeCache.clearCache();\n+ for (var entry : expectedMap.entrySet()) {\n+ Assert.assertEquals(entry.getValue(), hamt.get(entry.getKey()));\n+ }\n+ }\n+\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/test/java/org/modelix/model/TreeTestUtil.java", "diff": "+package org.modelix.model;\n+\n+import org.modelix.model.api.ITree;\n+\n+import java.util.Random;\n+import java.util.stream.LongStream;\n+import java.util.stream.Stream;\n+\n+public class TreeTestUtil {\n+ private ITree tree;\n+ private Random rand;\n+\n+ public TreeTestUtil(ITree tree, Random rand) {\n+ this.tree = tree;\n+ this.rand = rand;\n+ }\n+\n+ public LongStream getAncestors(long descendant, boolean includeSelf) {\n+ if (descendant == 0L) {\n+ return LongStream.empty();\n+ }\n+ if (includeSelf) {\n+ return LongStream.concat(LongStream.of(descendant), getAncestors(descendant, false));\n+ } else {\n+ long parent = tree.getParent(descendant);\n+ return getAncestors(parent, true);\n+ }\n+ }\n+\n+ public LongStream getAllNodes() {\n+ return getDescendants(ITree.ROOT_ID, true);\n+ }\n+\n+ public LongStream getAllNodesWithoutRoot() {\n+ return getDescendants(ITree.ROOT_ID, false);\n+ }\n+\n+ public LongStream getDescendants(long parent, boolean includeSelf) {\n+ if (includeSelf) {\n+ return LongStream.concat(LongStream.of(parent), getDescendants(parent, false));\n+ } else {\n+ return tree.getAllChildren(parent).flatMap(it -> getDescendants(it, true));\n+ }\n+ }\n+\n+ public long getRandomNodeWithoutRoot() {\n+ return getRandomNode(getAllNodesWithoutRoot().toArray());\n+ }\n+\n+ public long getRandomNodeWithRoot() {\n+ return getRandomNode(getAllNodes().toArray());\n+ }\n+\n+ public long getRandomNode(long[] nodes) {\n+ if (nodes.length == 0) {\n+ return 0L;\n+ }\n+ return LongStream.of(nodes).skip(rand.nextInt(nodes.length)).findFirst().orElse(0L);\n+ }\n+\n+ public long getRandomLeafNode() {\n+ return getRandomNode(getAllNodes().filter(it -> !tree.getAllChildren(it).iterator().hasNext()).toArray());\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/test/java/org/modelix/model/Tree_Test.java", "diff": "+package org.modelix.model;\n+\n+import io.vavr.Tuple;\n+import io.vavr.Tuple2;\n+import org.junit.Assert;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.modelix.model.api.ITree;\n+import org.modelix.model.api.PNodeReference;\n+import org.modelix.model.lazy.CLTree;\n+import org.modelix.model.lazy.ObjectStoreCache;\n+import org.modelix.model.persistent.MapBaseStore;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.HashMap;\n+import java.util.HashSet;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Objects;\n+import java.util.Random;\n+import java.util.Set;\n+\n+public class Tree_Test {\n+ private boolean DEBUG = false;\n+ private Map<Tuple2<Long, String>, List<Long>> expectedChildren;\n+ @Test\n+ public void test_random() throws Exception {\n+\n+ List<String> roles = Arrays.asList(\"role1\", \"role2\", \"role3\");\n+ Random rand = new Random(1906823);\n+ long idSequence = 1000000L;\n+\n+ MapBaseStore store = new MapBaseStore();\n+ ObjectStoreCache storeCache = new ObjectStoreCache(store);\n+ ITree tree = new CLTree(storeCache);\n+\n+ Map<Long, Long> expectedParents = new HashMap<>();\n+ Map<Long, String> expectedRoles = new HashMap<>();\n+ Set<Long> expectedDeletes = new HashSet<>();\n+\n+ for (int i = 0; i < 10000; i++) {\n+ switch (rand.nextInt(5)) {\n+ case 0:\n+ // Delete node\n+ {\n+ long nodeToDelete = new TreeTestUtil(tree, rand).getRandomLeafNode();\n+ if (nodeToDelete != 0L && nodeToDelete != ITree.ROOT_ID) {\n+ if (DEBUG) {\n+ System.out.println(\"Delete \" + nodeToDelete);\n+ }\n+ tree = tree.deleteNode(nodeToDelete);\n+ removeChild(expectedParents.get(nodeToDelete), expectedRoles.get(nodeToDelete), nodeToDelete);\n+ expectedParents.put(nodeToDelete, 0L);\n+ expectedRoles.remove(nodeToDelete);\n+ expectedDeletes.add(nodeToDelete);\n+ }\n+ }\n+ break;\n+ case 1:\n+ // New node\n+ {\n+ long parent = new TreeTestUtil(tree, rand).getRandomNodeWithRoot();\n+ if (parent != 0L) {\n+ long childId = ++idSequence;\n+ String role = roles.get(rand.nextInt(roles.size()));\n+ int index = (rand.nextBoolean() ? rand.nextInt((int) tree.getChildren(parent, role).count() + 1) : -1);\n+ if (DEBUG) {\n+ System.out.println(\"AddNew \" + childId + \" to \" + parent + \".\" + role + \"[\" + index + \"]\");\n+ }\n+ tree = tree.addNewChild(parent, role, index, childId, null);\n+ expectedParents.put(childId, parent);\n+ expectedRoles.put(childId, role);\n+ insertChild(parent, role, index, childId);\n+ }\n+ }\n+ break;\n+ case 2:\n+ // Set property\n+ {\n+ long nodeId = new TreeTestUtil(tree, rand).getRandomNodeWithoutRoot();\n+ if (nodeId != 0L) {\n+ String role = roles.get(rand.nextInt(roles.size()));\n+ String value = Long.toString(rand.nextLong());\n+ if (DEBUG) {\n+ System.out.println(\"SetProperty \" + nodeId + \".\" + role + \" = \" + value);\n+ }\n+ tree = tree.setProperty(nodeId, role, value);\n+ }\n+ }\n+\n+ break;\n+ case 3:\n+ // Set reference\n+ {\n+ long sourceId = new TreeTestUtil(tree, rand).getRandomNodeWithoutRoot();\n+ long targetId = new TreeTestUtil(tree, rand).getRandomNodeWithoutRoot();\n+ if (sourceId != 0L && targetId != 0L) {\n+ String role = roles.get(rand.nextInt(roles.size()));\n+ if (DEBUG) {\n+ System.out.println(\"SetReference \" + sourceId + \".\" + role + \" = \" + targetId);\n+ }\n+ tree = tree.setReferenceTarget(sourceId, role, new PNodeReference(targetId));\n+ }\n+ }\n+ break;\n+ case 4:\n+ // Move node\n+ {\n+ final TreeTestUtil util = new TreeTestUtil(tree, rand);\n+ final long childId = util.getRandomNodeWithoutRoot();\n+ long parent = util.getRandomNode(util\n+ .getAllNodes()\n+ .filter(it -> util.getAncestors(it, true).noneMatch(it2 -> it2 == childId))\n+ .toArray());\n+ if (childId != 0L && parent != 0L) {\n+ String role = roles.get(rand.nextInt(roles.size()));\n+ int index = (rand.nextBoolean() ? rand.nextInt((int) tree.getChildren(parent, role).count() + 1) : -1);\n+ if (DEBUG) {\n+ System.out.println(\"MoveNode \" + childId + \" to \" + parent + \".\" + role + \"[\" + index + \"]\");\n+ }\n+ tree = tree.moveChild(parent, role, index, childId);\n+ long oldParent = expectedParents.get(childId);\n+ String oldRole = expectedRoles.get(childId);\n+ if (Objects.equals(oldParent, parent) && Objects.equals(oldRole, role)) {\n+ int oldIndex = expectedChildren.get(Tuple.of(oldParent, oldRole)).indexOf(childId);\n+ if (oldIndex < index) {\n+ index--;\n+ }\n+ }\n+ removeChild(oldParent, oldRole, childId);\n+ expectedParents.put(childId, parent);\n+ expectedRoles.put(childId, role);\n+ insertChild(parent, role, index, childId);\n+ }\n+ }\n+ break;\n+ }\n+\n+ for (var entry : expectedParents.entrySet()) {\n+ if (Objects.equals(entry.getValue(), 0L)) {\n+ Assert.assertFalse(tree.containsNode(entry.getKey()));\n+ } else {\n+ long expectedParent = entry.getValue();\n+ long actualParent = tree.getParent(entry.getKey());\n+ Assert.assertEquals(expectedParent, actualParent);\n+ }\n+ }\n+\n+ for (var entry : expectedChildren.entrySet()) {\n+ if (expectedDeletes.contains((long) entry.getKey()._1())) {\n+ continue;\n+ }\n+ long[] expected = entry.getValue().stream().mapToLong(it -> it).toArray();\n+ long[] actual = tree.getChildren((long) entry.getKey()._1(), entry.getKey()._2()).toArray();\n+ Assert.assertArrayEquals(expected, actual);\n+ }\n+\n+ for (var entry : expectedRoles.entrySet()) {\n+ Assert.assertEquals(entry.getValue(), tree.getRole(entry.getKey()));\n+ }\n+\n+ for (long node : expectedDeletes) {\n+ Assert.assertFalse(tree.containsNode(node));\n+ }\n+ }\n+\n+ }\n+ @Before\n+ public void setUp() {\n+ expectedChildren = new HashMap<>();\n+ }\n+ public void insertChild(long parent, String role, int index, long child) {\n+ List<Long> list = expectedChildren.computeIfAbsent(Tuple.of(parent, role), k -> new ArrayList<>());\n+ if (index == -1) {\n+ list.add(child);\n+ } else {\n+ list.add(index, child);\n+ }\n+ }\n+ public void removeChild(long parent, String role, long child) {\n+ List<Long> list = expectedChildren.computeIfAbsent(Tuple.of(parent, role), k -> new ArrayList<>());\n+ list.remove(child);\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Copied tests from MPS
426,504
01.08.2020 11:08:25
-7,200
ebde33884da95ade388549e14260c6dab6f7e8f5
initial Kotlin configuration
[ { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "+buildscript {\n+ ext.kotlinVersion = '1.3.72'\n+}\n+\nplugins {\nid 'java'\n+ id \"org.jetbrains.kotlin.jvm\" version \"${kotlinVersion}\"\n+}\n+\n+configurations {\n+ ktlint\n+}\n+\n+dependencies {\n+ ktlint \"com.pinterest:ktlint:0.37.2\"\n+}\n+\n+task ktlint(type: JavaExec, group: \"verification\") {\n+ description = \"Check Kotlin code style.\"\n+ classpath = configurations.ktlint\n+ main = \"com.pinterest.ktlint.Main\"\n+ args \"src/**/*.kt\"\n+}\n+check.dependsOn ktlint\n+\n+task ktlintFormat(type: JavaExec, group: \"formatting\") {\n+ description = \"Fix Kotlin code style deviations.\"\n+ classpath = configurations.ktlint\n+ main = \"com.pinterest.ktlint.Main\"\n+ args \"-F\", \"src/**/*.kt\"\n}\ngroup 'org.modelix'\n@@ -21,5 +49,4 @@ dependencies {\ncompile group: 'org.json', name: 'json', version: '20200518'\ncompile group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3'\ncompile group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'\n-\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
initial Kotlin configuration
426,504
01.08.2020 11:17:04
-7,200
bf7472806c9cc9bd76f58ee59eaa5f001abad2a6
migrate IKeyListener to Kotlin
[ { "change_type": "MODIFY", "old_path": "model-client/.idea/gradle.xml", "new_path": "model-client/.idea/gradle.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n+ <component name=\"GradleMigrationSettings\" migrationVersion=\"1\" />\n<component name=\"GradleSettings\">\n<option name=\"linkedExternalProjectsSettings\">\n<GradleProjectSettings>\n" }, { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "@@ -49,4 +49,6 @@ dependencies {\ncompile group: 'org.json', name: 'json', version: '20200518'\ncompile group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3'\ncompile group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'\n+ compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlinVersion\n+\n}\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/IKeyListener.java", "new_path": null, "diff": "-package org.modelix.model;\n-\n-public interface IKeyListener {\n- void changed(String key, String value);\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/client/AsyncStore.java", "new_path": "model-client/src/main/java/org/modelix/model/client/AsyncStore.java", "diff": "@@ -3,9 +3,9 @@ package org.modelix.model.client;\nimport org.apache.log4j.Level;\nimport org.apache.log4j.LogManager;\nimport org.apache.log4j.Logger;\n-import org.modelix.model.util.StreamUtils;\nimport org.modelix.model.IKeyListener;\nimport org.modelix.model.IKeyValueStore;\n+import org.modelix.model.util.StreamUtils;\nimport java.util.Iterator;\nimport java.util.LinkedHashMap;\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/client/GarbageFilteringStore.java", "new_path": "model-client/src/main/java/org/modelix/model/client/GarbageFilteringStore.java", "diff": "package org.modelix.model.client;\n-import org.modelix.model.util.StreamUtils;\nimport org.modelix.model.IKeyListener;\nimport org.modelix.model.IKeyValueStore;\n+import org.modelix.model.util.StreamUtils;\nimport org.modelix.model.persistent.HashUtil;\nimport java.util.Collections;\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/client/RestWebModelClient.java", "new_path": "model-client/src/main/java/org/modelix/model/client/RestWebModelClient.java", "diff": "package org.modelix.model.client;\n+import org.modelix.model.IKeyListener;\n+import org.modelix.model.IKeyValueStore;\nimport org.modelix.model.api.IIdGenerator;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.log4j.Level;\n@@ -8,8 +10,6 @@ import org.apache.log4j.Logger;\nimport org.json.JSONArray;\nimport org.json.JSONObject;\nimport org.modelix.model.util.StreamUtils;\n-import org.modelix.model.IKeyListener;\n-import org.modelix.model.IKeyValueStore;\nimport org.modelix.model.KeyValueStoreCache;\nimport org.modelix.model.lazy.IDeserializingKeyValueStore;\nimport org.modelix.model.lazy.ObjectStoreCache;\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/client/VersionChangeDetector.java", "new_path": "model-client/src/main/java/org/modelix/model/client/VersionChangeDetector.java", "diff": "@@ -2,11 +2,12 @@ package org.modelix.model.client;\nimport org.apache.log4j.Logger;\nimport org.apache.log4j.LogManager;\n-import org.modelix.model.IKeyListener;\n-import org.modelix.model.IKeyValueStore;\n+\nimport java.util.concurrent.ScheduledFuture;\nimport java.util.Objects;\nimport org.apache.log4j.Level;\n+import org.modelix.model.IKeyListener;\n+import org.modelix.model.IKeyValueStore;\npublic abstract class VersionChangeDetector {\nprivate static final Logger LOG = LogManager.getLogger(VersionChangeDetector.class);\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/ObjectStoreCache.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/ObjectStoreCache.java", "diff": "package org.modelix.model.lazy;\nimport org.apache.commons.collections4.map.LRUMap;\n-import org.modelix.model.util.StreamUtils;\nimport org.modelix.model.IKeyValueStore;\n+import org.modelix.model.util.StreamUtils;\nimport java.util.ArrayList;\nimport java.util.Collections;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/IKeyListener.kt", "diff": "+package org.modelix.model\n+\n+interface IKeyListener {\n+ fun changed(key: String?, value: String?)\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate IKeyListener to Kotlin
426,504
01.08.2020 11:20:07
-7,200
64e3dc5493292d0741044563027349ed294c8894
migrate IKeyValueStore
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/IKeyValueStore.java", "new_path": null, "diff": "-package org.modelix.model;\n-\n-import java.util.Map;\n-\n-public interface IKeyValueStore {\n- String get(String key);\n- void put(String key, String value);\n- Map<String, String> getAll(Iterable<String> keys);\n- void putAll(Map<String, String> entries);\n-\n- void prefetch(String key);\n-\n- void listen(final String key, final IKeyListener listener);\n- void removeListener(final String key, final IKeyListener listener);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/IKeyValueStore.kt", "diff": "+package org.modelix.model\n+\n+\n+interface IKeyValueStore {\n+ operator fun get(key: String?): String?\n+ fun put(key: String?, value: String?)\n+ fun getAll(keys: Iterable<String?>?): Map<String?, String?>?\n+ fun putAll(entries: Map<String?, String?>?)\n+ fun prefetch(key: String?)\n+ fun listen(key: String?, listener: IKeyListener?)\n+ fun removeListener(key: String?, listener: IKeyListener?)\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate IKeyValueStore
426,504
01.08.2020 12:08:35
-7,200
482499f82cb0160b39a8e1a2c5c95fb234231808
specify JVM target 1.8
[ { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "@@ -50,5 +50,10 @@ dependencies {\ncompile group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3'\ncompile group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'\ncompile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlinVersion\n+}\n+tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {\n+ kotlinOptions {\n+ jvmTarget = \"1.8\"\n+ }\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
specify JVM target 1.8
426,504
01.08.2020 12:10:47
-7,200
d4c61df3ddad52424b44a3862138c023775aa483
migrate VersionMerger
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/VersionMerger.java", "new_path": null, "diff": "-package org.modelix.model;\n-\n-import org.modelix.model.api.IBranch;\n-import org.modelix.model.api.IIdGenerator;\n-import org.modelix.model.api.ITree;\n-import org.modelix.model.api.IWriteTransaction;\n-import org.modelix.model.api.PBranch;\n-import gnu.trove.set.TLongSet;\n-import gnu.trove.set.hash.TLongHashSet;\n-import org.apache.commons.lang3.mutable.MutableObject;\n-import org.jetbrains.annotations.NotNull;\n-import org.jetbrains.annotations.Nullable;\n-import org.modelix.model.util.StreamUtils;\n-import org.modelix.model.lazy.CLTree;\n-import org.modelix.model.lazy.CLVersion;\n-import org.modelix.model.lazy.IDeserializingKeyValueStore;\n-import org.modelix.model.operations.IAppliedOperation;\n-import org.modelix.model.operations.IOperation;\n-import org.modelix.model.persistent.CPVersion;\n-\n-import java.util.ArrayList;\n-import java.util.HashSet;\n-import java.util.List;\n-import java.util.Objects;\n-import java.util.Optional;\n-import java.util.Set;\n-import java.util.stream.Collectors;\n-\n-public class VersionMerger {\n-\n- private final Object mergeLock = new Object();\n-\n- private IDeserializingKeyValueStore storeCache;\n- private IIdGenerator idGenerator;\n-\n- public VersionMerger(IDeserializingKeyValueStore storeCache, IIdGenerator idGenerator) {\n- this.storeCache = storeCache;\n- this.idGenerator = idGenerator;\n- }\n-\n- @NotNull\n- public CLVersion mergeChange(CLVersion lastMergedVersion, @NotNull CLVersion newVersion) {\n- synchronized (mergeLock) {\n- if (lastMergedVersion == null) {\n- lastMergedVersion = newVersion;\n- return newVersion;\n- } else {\n- if (Objects.equals(newVersion.getHash(), lastMergedVersion.getHash())) {\n- return lastMergedVersion;\n- }\n- CLVersion merged = mergeHistory(lastMergedVersion.getHash(), newVersion.getHash());\n- checkTreeIds(lastMergedVersion, newVersion);\n- return merged;\n- }\n- }\n- }\n-\n- public void checkTreeIds(CLVersion v1, CLVersion v2) {\n- String id1 = v1.getTree().getId();\n- String id2 = v2.getTree().getId();\n- if (!(Objects.equals(id1, id2))) {\n- throw new RuntimeException(\"Tree ID mismatch: \" + id1 + \" and \" + id2);\n- }\n- }\n-\n- @NotNull\n- protected CLVersion mergeHistory(String leftVersionHash, String rightVersionHash) {\n- String commonBase = commonBaseVersion(leftVersionHash, rightVersionHash);\n-\n- final List<CLVersion> leftHistory = getHistory(leftVersionHash, commonBase);\n- final List<CLVersion> rightHistory = getHistory(rightVersionHash, commonBase);\n-\n- final MutableObject<CLVersion> mergedVersion = new MutableObject<>();\n-\n- CLTree tree = getVersion(commonBase).getTree();\n- if (tree == null) {\n- tree = new CLTree(storeCache);\n- }\n- final IBranch branch = new PBranch(tree);\n-\n- if (rightHistory.isEmpty() || leftHistory.isEmpty()) {\n- List<CLVersion> fastForwardHistory = leftHistory.isEmpty() ? rightHistory : leftHistory;\n- int numOps = fastForwardHistory.stream().map(CLVersion::getNumberOfOperations).reduce(0, Math::max);\n- if (numOps > 100) {\n- return fastForwardHistory.get(0);\n- }\n- // A small number of changes may be faster to compute locally.\n- }\n-\n- branch.runWrite(() -> {\n- IWriteTransaction t = branch.getWriteTransaction();\n-\n- List<IAppliedOperation> leftAppliedOps = new ArrayList<>();\n- List<IAppliedOperation> rightAppliedOps = new ArrayList<>();\n- TLongSet appliedVersionIds = new TLongHashSet();\n- while (!leftHistory.isEmpty() || !rightHistory.isEmpty()) {\n- boolean useLeft = rightHistory.isEmpty() || !leftHistory.isEmpty() && StreamUtils.last(leftHistory).getId() < StreamUtils.last(rightHistory).getId();\n- CLVersion versionToApply = StreamUtils.removeLast(useLeft ? leftHistory : rightHistory);\n- if (appliedVersionIds.contains(versionToApply.getId())) {\n- continue;\n- }\n- appliedVersionIds.add(versionToApply.getId());\n- final List<IOperation> oppositeAppliedOps = (useLeft ? rightAppliedOps : leftAppliedOps).stream()\n- .map(IAppliedOperation::getOriginalOp)\n- .collect(Collectors.toList());\n- List<IOperation> operationsToApply = StreamUtils.toStream(versionToApply.getOperations())\n- .map(it -> transformOperation(it, oppositeAppliedOps))\n- .collect(Collectors.toList());\n- for (IOperation op : operationsToApply) {\n- IAppliedOperation appliedOp = op.apply(t);\n- if (useLeft) {\n- leftAppliedOps.add(appliedOp);\n- } else {\n- rightAppliedOps.add(appliedOp);\n- }\n- }\n-\n- mergedVersion.setValue(new CLVersion(\n- versionToApply.getId(),\n- versionToApply.getTime(),\n- versionToApply.getAuthor(),\n- ((CLTree) t.getTree()).getHash(),\n- mergedVersion.getValue() != null\n- ? mergedVersion.getValue().getHash()\n- : versionToApply.getPreviousHash(),\n- operationsToApply.toArray(new IOperation[operationsToApply.size()]),\n- storeCache\n- ));\n- }\n- });\n-\n- if (mergedVersion.getValue() == null) {\n- throw new RuntimeException(\"Failed to merge \" + leftVersionHash + \" and \" + rightVersionHash);\n- }\n-\n- return mergedVersion.getValue();\n- }\n-\n- protected IOperation transformOperation(IOperation opToTransform, Iterable<IOperation> previousOps) {\n- IOperation result = opToTransform;\n- for (IOperation previous : previousOps) {\n- result = result.transform(previous);\n- }\n- return result;\n- }\n-\n- /**\n- *\n- *\n- * @param fromVersion The newest version\n- * @param toVersionExclusive The oldest version\n- * @return Newest version first\n- */\n- protected List<CLVersion> getHistory(@NotNull String fromVersion, @Nullable String toVersionExclusive) {\n- List<CLVersion> history = new ArrayList<CLVersion>();\n- if (Objects.equals(fromVersion, toVersionExclusive)) {\n- return history;\n- }\n- CLVersion version = getVersion(fromVersion);\n- while (true) {\n- if (version == null) {\n- break;\n- }\n- history.add(version);\n- if (version.getPreviousHash() == null) {\n- break;\n- }\n- if (Objects.equals(version.getPreviousHash(), toVersionExclusive)) {\n- break;\n- }\n- version = version.getPreviousVersion();\n- }\n- return history;\n- }\n-\n- protected String commonBaseVersion(String leftHash, String rightHash) {\n-\n- Set<String> leftVersions = new HashSet<>();\n- Set<String> rightVersions = new HashSet<>();\n-\n- while (leftHash != null || rightHash != null) {\n- if (leftHash != null) {\n- leftVersions.add(leftHash);\n- }\n- if (rightHash != null) {\n- rightVersions.add(rightHash);\n- }\n-\n- if (leftHash != null) {\n- if (rightVersions.contains(leftHash)) {\n- return leftHash;\n- }\n- }\n- if (rightHash != null) {\n- if (leftVersions.contains(rightHash)) {\n- return rightHash;\n- }\n- }\n-\n- if (leftHash != null) {\n- leftHash = Optional.ofNullable(getVersion(leftHash)).map(CLVersion::getPreviousHash).orElse(null);\n- }\n- if (rightHash != null) {\n- rightHash = Optional.ofNullable(getVersion(rightHash)).map(CLVersion::getPreviousHash).orElse(null);\n- }\n- }\n-\n- return null;\n- }\n-\n- private @Nullable CLVersion getVersion(String hash) {\n- if (hash == null) {\n- return null;\n- }\n- return CLVersion.loadFromHash(hash, storeCache);\n- }\n-\n- protected ITree getTree(CPVersion version) {\n- if (version == null) {\n- return null;\n- }\n- return new CLTree(version.treeHash, storeCache);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "diff": "+package org.modelix.model\n+\n+import gnu.trove.set.TLongSet\n+import gnu.trove.set.hash.TLongHashSet\n+import org.apache.commons.lang3.mutable.MutableObject\n+import org.modelix.model.api.IBranch\n+import org.modelix.model.api.IIdGenerator\n+import org.modelix.model.api.ITree\n+import org.modelix.model.api.PBranch\n+import org.modelix.model.lazy.CLTree\n+import org.modelix.model.lazy.CLVersion\n+import org.modelix.model.lazy.IDeserializingKeyValueStore\n+import org.modelix.model.operations.IAppliedOperation\n+import org.modelix.model.operations.IOperation\n+import org.modelix.model.persistent.CPVersion\n+import org.modelix.model.util.StreamUtils\n+import java.util.*\n+import java.util.stream.Collectors\n+\n+class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private val idGenerator: IIdGenerator) {\n+ private val mergeLock = Any()\n+ fun mergeChange(lastMergedVersion: CLVersion, newVersion: CLVersion): CLVersion {\n+ var lastMergedVersion = lastMergedVersion\n+ synchronized(mergeLock) {\n+ return if (lastMergedVersion == null) {\n+ lastMergedVersion = newVersion\n+ newVersion\n+ } else {\n+ if (newVersion.hash == lastMergedVersion.hash) {\n+ return lastMergedVersion\n+ }\n+ val merged = mergeHistory(lastMergedVersion.hash, newVersion.hash)\n+ checkTreeIds(lastMergedVersion, newVersion)\n+ merged\n+ }\n+ }\n+ }\n+\n+ fun checkTreeIds(v1: CLVersion, v2: CLVersion) {\n+ val id1 = v1.tree.id\n+ val id2 = v2.tree.id\n+ if (id1 != id2) {\n+ throw RuntimeException(\"Tree ID mismatch: $id1 and $id2\")\n+ }\n+ }\n+\n+ protected fun mergeHistory(leftVersionHash: String, rightVersionHash: String): CLVersion {\n+ val commonBase = commonBaseVersion(leftVersionHash, rightVersionHash)\n+ val leftHistory = getHistory(leftVersionHash, commonBase)\n+ val rightHistory = getHistory(rightVersionHash, commonBase)\n+ val mergedVersion = MutableObject<CLVersion>()\n+ var tree = getVersion(commonBase)!!.tree\n+ if (tree == null) {\n+ tree = CLTree(storeCache)\n+ }\n+ val branch: IBranch = PBranch(tree)\n+ if (rightHistory.isEmpty() || leftHistory.isEmpty()) {\n+ val fastForwardHistory = if (leftHistory.isEmpty()) rightHistory else leftHistory\n+ val numOps = fastForwardHistory.stream().map { obj: CLVersion -> obj.numberOfOperations }.reduce(0) { a: Int, b: Int -> Math.max(a, b) }\n+ if (numOps > 100) {\n+ return fastForwardHistory[0]\n+ }\n+ // A small number of changes may be faster to compute locally.\n+ }\n+ branch.runWrite {\n+ val t = branch.writeTransaction\n+ val leftAppliedOps: MutableList<IAppliedOperation> = ArrayList()\n+ val rightAppliedOps: MutableList<IAppliedOperation> = ArrayList()\n+ val appliedVersionIds: TLongSet = TLongHashSet()\n+ while (!leftHistory.isEmpty() || !rightHistory.isEmpty()) {\n+ val useLeft = rightHistory.isEmpty() || !leftHistory.isEmpty() && StreamUtils.last(leftHistory).id < StreamUtils.last(rightHistory).id\n+ val versionToApply = StreamUtils.removeLast(if (useLeft) leftHistory else rightHistory)\n+ if (appliedVersionIds.contains(versionToApply.id)) {\n+ continue\n+ }\n+ appliedVersionIds.add(versionToApply.id)\n+ val oppositeAppliedOps = (if (useLeft) rightAppliedOps else leftAppliedOps).stream()\n+ .map { obj: IAppliedOperation -> obj.originalOp }\n+ .collect(Collectors.toList())\n+ val operationsToApply = StreamUtils.toStream(versionToApply.operations)\n+ .map { it: IOperation -> transformOperation(it, oppositeAppliedOps) }\n+ .collect(Collectors.toList())\n+ for (op in operationsToApply) {\n+ val appliedOp = op.apply(t)\n+ if (useLeft) {\n+ leftAppliedOps.add(appliedOp)\n+ } else {\n+ rightAppliedOps.add(appliedOp)\n+ }\n+ }\n+ mergedVersion.value = CLVersion(\n+ versionToApply.id,\n+ versionToApply.time,\n+ versionToApply.author,\n+ (t.tree as CLTree).hash,\n+ if (mergedVersion.value != null) mergedVersion.value.hash else versionToApply.previousHash,\n+ operationsToApply.toTypedArray(),\n+ storeCache\n+ )\n+ }\n+ }\n+ if (mergedVersion.value == null) {\n+ throw RuntimeException(\"Failed to merge $leftVersionHash and $rightVersionHash\")\n+ }\n+ return mergedVersion.value\n+ }\n+\n+ protected fun transformOperation(opToTransform: IOperation, previousOps: Iterable<IOperation?>): IOperation {\n+ var result = opToTransform\n+ for (previous in previousOps) {\n+ result = result.transform(previous)\n+ }\n+ return result\n+ }\n+\n+ /**\n+ *\n+ *\n+ * @param fromVersion The newest version\n+ * @param toVersionExclusive The oldest version\n+ * @return Newest version first\n+ */\n+ protected fun getHistory(fromVersion: String, toVersionExclusive: String?): List<CLVersion> {\n+ val history: MutableList<CLVersion> = ArrayList()\n+ if (fromVersion == toVersionExclusive) {\n+ return history\n+ }\n+ var version = getVersion(fromVersion)\n+ while (true) {\n+ if (version == null) {\n+ break\n+ }\n+ history.add(version)\n+ if (version.previousHash == null) {\n+ break\n+ }\n+ if (version.previousHash == toVersionExclusive) {\n+ break\n+ }\n+ version = version.previousVersion\n+ }\n+ return history\n+ }\n+\n+ protected fun commonBaseVersion(leftHash: String?, rightHash: String?): String? {\n+ var leftHash = leftHash\n+ var rightHash = rightHash\n+ val leftVersions: MutableSet<String> = HashSet()\n+ val rightVersions: MutableSet<String> = HashSet()\n+ while (leftHash != null || rightHash != null) {\n+ if (leftHash != null) {\n+ leftVersions.add(leftHash)\n+ }\n+ if (rightHash != null) {\n+ rightVersions.add(rightHash)\n+ }\n+ if (leftHash != null) {\n+ if (rightVersions.contains(leftHash)) {\n+ return leftHash\n+ }\n+ }\n+ if (rightHash != null) {\n+ if (leftVersions.contains(rightHash)) {\n+ return rightHash\n+ }\n+ }\n+ if (leftHash != null) {\n+ leftHash = Optional.ofNullable(getVersion(leftHash)).map { obj: CLVersion -> obj.previousHash }.orElse(null)\n+ }\n+ if (rightHash != null) {\n+ rightHash = Optional.ofNullable(getVersion(rightHash)).map { obj: CLVersion -> obj.previousHash }.orElse(null)\n+ }\n+ }\n+ return null\n+ }\n+\n+ private fun getVersion(hash: String?): CLVersion? {\n+ return if (hash == null) {\n+ null\n+ } else CLVersion.loadFromHash(hash, storeCache)\n+ }\n+\n+ protected fun getTree(version: CPVersion?): ITree? {\n+ return if (version == null) {\n+ null\n+ } else CLTree(version.treeHash, storeCache)\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate VersionMerger
426,504
01.08.2020 12:15:35
-7,200
f158f8a4e0d056007ad02583855c6e2354dd0ed1
convert ContextValue and StreamUtils
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/KeyValueStoreCache.java", "new_path": "model-client/src/main/java/org/modelix/model/KeyValueStoreCache.java", "diff": "@@ -68,7 +68,7 @@ public class KeyValueStoreCache implements IKeyValueStore {\n@Override\npublic Map<String, String> getAll(Iterable<String> keys_) {\n- List<String> remainingKeys = StreamUtils.toStream(keys_).collect(Collectors.toList());\n+ List<String> remainingKeys = StreamUtils.INSTANCE.toStream(keys_).collect(Collectors.toList());\nMap<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\nsynchronized (cache) {\nIterator<String> itr = remainingKeys.iterator();\n@@ -90,7 +90,7 @@ public class KeyValueStoreCache implements IKeyValueStore {\nfor (final GetRequest r : activeRequests) {\nif (remainingKeys.stream().anyMatch(r.keys::contains)) {\nif (LOG.isDebugEnabled()) {\n- Set<String> intersection = StreamUtils.intersection(remainingKeys.stream(), r.keys);\n+ Set<String> intersection = StreamUtils.INSTANCE.intersection(remainingKeys.stream(), r.keys);\nLOG.debug(\"Reusing an active request: \" + intersection.stream().findFirst().orElse(null) + \" (\" + intersection.size() + \")\");\n}\nrequiredRequest.add(r);\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/api/CompositeNodeResolveContext.java", "new_path": "model-client/src/main/java/org/modelix/model/api/CompositeNodeResolveContext.java", "diff": "@@ -20,7 +20,7 @@ public class CompositeNodeResolveContext implements INodeResolveContext {\nprivate List<INodeResolveContext> contexts;\npublic CompositeNodeResolveContext(Iterable<INodeResolveContext> contexts) {\n- this.contexts = StreamUtils.toStream(contexts).collect(Collectors.toList());\n+ this.contexts = StreamUtils.INSTANCE.toStream(contexts).collect(Collectors.toList());\n}\npublic CompositeNodeResolveContext(INodeResolveContext... contexts) {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/client/AsyncStore.java", "new_path": "model-client/src/main/java/org/modelix/model/client/AsyncStore.java", "diff": "@@ -56,7 +56,7 @@ public class AsyncStore implements IKeyValueStore {\n@Override\npublic Map<String, String> getAll(Iterable<String> keys_) {\n- List<String> keys = StreamUtils.toStream(keys_).collect(Collectors.toList());\n+ List<String> keys = StreamUtils.INSTANCE.toStream(keys_).collect(Collectors.toList());\nMap<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\nsynchronized (pendingWrites) {\nIterator<String> itr = keys.iterator();\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/client/GarbageFilteringStore.java", "new_path": "model-client/src/main/java/org/modelix/model/client/GarbageFilteringStore.java", "diff": "@@ -34,7 +34,7 @@ public class GarbageFilteringStore implements IKeyValueStore {\n@Override\npublic Map<String, String> getAll(Iterable<String> keys_) {\n- List<String> keys = StreamUtils.toStream(keys_).collect(Collectors.toList());\n+ List<String> keys = StreamUtils.INSTANCE.toStream(keys_).collect(Collectors.toList());\nMap<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\nsynchronized (pendingEntries) {\nIterator<String> itr = keys.iterator();\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/client/RestWebModelClient.java", "new_path": "model-client/src/main/java/org/modelix/model/client/RestWebModelClient.java", "diff": "@@ -189,7 +189,7 @@ public class RestWebModelClient implements IModelClient {\n} else {\nthrow new RuntimeException(String.format(\"Request for %d keys failed (%s, ...): %s\",\nkeys.spliterator().getExactSizeIfKnown(),\n- StreamUtils.toStream(keys).findFirst().orElse(null),\n+ StreamUtils.INSTANCE.toStream(keys).findFirst().orElse(null),\nresponse.getStatusInfo()));\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "diff": "@@ -344,7 +344,7 @@ public class CLTree implements ITree {\nif (oldParent == targetParentId) {\nString oldRole = getRole(childId);\nif (Objects.equals(oldRole, targetRole)) {\n- int oldIndex = StreamUtils.indexOf(getChildren(oldParent, oldRole), childId);\n+ int oldIndex = StreamUtils.INSTANCE.indexOf(getChildren(oldParent, oldRole), childId);\nif (oldIndex == targetIndex) {\nreturn this;\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.java", "diff": "@@ -17,7 +17,7 @@ public class NonBulkQuery implements IBulkQuery {\n@Override\npublic <I, O> IBulkQuery.Value<List<O>> map(Iterable<I> input, final Function<I, IBulkQuery.Value<O>> f) {\n- List<O> list = StreamUtils.toStream(input).map(f).map(IBulkQuery.Value::execute).collect(Collectors.toList());\n+ List<O> list = StreamUtils.INSTANCE.toStream(input).map(f).map(IBulkQuery.Value::execute).collect(Collectors.toList());\nreturn new Value<List<O>>(list);\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/ObjectStoreCache.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/ObjectStoreCache.java", "diff": "@@ -30,7 +30,7 @@ public class ObjectStoreCache implements IDeserializingKeyValueStore {\n@Override\npublic <T> Iterable<T> getAll(Iterable<String> hashes_, BiFunction<String, String, T> deserializer) {\n- List<String> hashes = StreamUtils.toStream(hashes_).collect(Collectors.toList());\n+ List<String> hashes = StreamUtils.INSTANCE.toStream(hashes_).collect(Collectors.toList());\nfinal Map<String, T> result = new HashMap<>();\nList<String> nonCachedHashes = new ArrayList<>(hashes.size());\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.java", "new_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.java", "diff": "@@ -39,7 +39,7 @@ public class OTWriteTransaction implements IWriteTransaction {\npublic void moveChild(long newParentId, String newRole, int newIndex, long childId) {\nlong oldparent = getParent(childId);\nString oldRole = getRole(childId);\n- int oldIndex = StreamUtils.indexOf(getChildren(oldparent, oldRole), childId);\n+ int oldIndex = StreamUtils.INSTANCE.indexOf(getChildren(oldparent, oldRole), childId);\nif (newIndex == -1) {\nnewIndex = (int) getChildren(newParentId, newRole).count();\n}\n@@ -68,7 +68,7 @@ public class OTWriteTransaction implements IWriteTransaction {\npublic void deleteNode(long nodeId) {\nlong parent = getParent(nodeId);\nString role = getRole(nodeId);\n- int index = StreamUtils.indexOf(getChildren(parent, role), nodeId);\n+ int index = StreamUtils.INSTANCE.indexOf(getChildren(parent, role), nodeId);\napply(new DeleteNodeOp(parent, role, index, nodeId));\n}\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/util/ContextValue.java", "new_path": null, "diff": "-package org.modelix.model.util;\n-\n-import java.util.ArrayList;\n-import java.util.List;\n-import java.util.function.Supplier;\n-\n-public class ContextValue<E> {\n-\n- private E defaultValue;\n- private final ThreadLocal<List<E>> value = new ThreadLocal<>();\n-\n- public ContextValue() {\n- }\n-\n- public ContextValue(E defaultValue) {\n- this.defaultValue = defaultValue;\n- }\n-\n- private List<E> getStack() {\n- List<E> stack = value.get();\n- if (stack == null) {\n- stack = new ArrayList<>();\n- value.set(stack);\n- }\n- return stack;\n- }\n-\n- public void runWith(E newValue, Runnable r) {\n- try {\n- getStack().add(newValue);\n- r.run();\n- } finally {\n- List<E> stack = getStack();\n- stack.remove(stack.size() - 1);\n- }\n- }\n-\n- public <T> T computeWith(E newValue, Supplier<T> r) {\n- try {\n- getStack().add(newValue);\n- return r.get();\n- } finally {\n- List<E> stack = getStack();\n- stack.remove(stack.size() - 1);\n- }\n- }\n-\n- public E getValue() {\n- List<E> stack = getStack();\n- return stack.isEmpty() ? defaultValue : stack.get(stack.size() - 1);\n- }\n-\n- public Iterable<E> getAllValues() {\n- return getStack();\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/util/ContextValue.kt", "diff": "+package org.modelix.model.util\n+\n+import java.util.*\n+import java.util.function.Supplier\n+\n+class ContextValue<E> {\n+ private var defaultValue: E? = null\n+ private val value = ThreadLocal<MutableList<E>>()\n+\n+ constructor() {}\n+ constructor(defaultValue: E) {\n+ this.defaultValue = defaultValue\n+ }\n+\n+ private val stack: MutableList<E>\n+ private get() {\n+ var stack = value.get()\n+ if (stack == null) {\n+ stack = ArrayList()\n+ value.set(stack)\n+ }\n+ return stack\n+ }\n+\n+ fun runWith(newValue: E, r: Runnable) {\n+ try {\n+ stack.add(newValue)\n+ r.run()\n+ } finally {\n+ val stack: MutableList<E> = stack\n+ stack.removeAt(stack.size - 1)\n+ }\n+ }\n+\n+ fun <T> computeWith(newValue: E, r: Supplier<T>): T {\n+ return try {\n+ stack.add(newValue)\n+ r.get()\n+ } finally {\n+ val stack: MutableList<E> = stack\n+ stack.removeAt(stack.size - 1)\n+ }\n+ }\n+\n+ fun getValue(): E? {\n+ val stack: List<E> = stack\n+ return if (stack.isEmpty()) defaultValue else stack[stack.size - 1]\n+ }\n+\n+ val allValues: Iterable<E>\n+ get() = stack\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/util/StreamUtils.java", "new_path": null, "diff": "-package org.modelix.model.util;\n-\n-import java.util.List;\n-import java.util.PrimitiveIterator;\n-import java.util.Set;\n-import java.util.stream.Collectors;\n-import java.util.stream.LongStream;\n-import java.util.stream.Stream;\n-import java.util.stream.StreamSupport;\n-\n-public class StreamUtils {\n- public static <T> Stream<T> toStream(Iterable<T> iterable) {\n- return StreamSupport.stream(iterable.spliterator(), false);\n- }\n-\n- public static int indexOf(LongStream stream, long value) {\n- PrimitiveIterator.OfLong iterator = stream.iterator();\n- int index = 0;\n- while (iterator.hasNext()) {\n- if (iterator.nextLong() == value) {\n- return index;\n- }\n- index++;\n- }\n- return -1;\n- }\n-\n- public static <T> Set<T> intersection(Stream<T> a, Set<T> b) {\n- return a.filter(b::contains).collect(Collectors.toSet());\n- }\n-\n- public static <T> T last(List<T> list) {\n- return list.isEmpty() ? null : list.get(list.size() - 1);\n- }\n-\n- public static <T> T removeLast(List<T> list) {\n- return list.isEmpty() ? null : list.remove(list.size() - 1);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/util/StreamUtils.kt", "diff": "+package org.modelix.model.util\n+\n+import java.util.stream.Collectors\n+import java.util.stream.LongStream\n+import java.util.stream.Stream\n+import java.util.stream.StreamSupport\n+\n+object StreamUtils {\n+ fun <T> toStream(iterable: Iterable<T>): Stream<T> {\n+ return StreamSupport.stream(iterable.spliterator(), false)\n+ }\n+\n+ fun indexOf(stream: LongStream, value: Long): Int {\n+ val iterator = stream.iterator()\n+ var index = 0\n+ while (iterator.hasNext()) {\n+ if (iterator.nextLong() == value) {\n+ return index\n+ }\n+ index++\n+ }\n+ return -1\n+ }\n+\n+ fun <T> intersection(a: Stream<T>, b: Set<T>): Set<T> {\n+ return a.filter { o: T -> b.contains(o) }.collect(Collectors.toSet())\n+ }\n+\n+ fun <T> last(list: List<T>): T? {\n+ return if (list.isEmpty()) null else list[list.size - 1]\n+ }\n+\n+ fun <T> removeLast(list: MutableList<T>): T? {\n+ return if (list.isEmpty()) null else list.removeAt(list.size - 1)\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/util/pmap/SmallPMap.java", "new_path": "model-client/src/main/java/org/modelix/model/util/pmap/SmallPMap.java", "diff": "@@ -24,8 +24,8 @@ public abstract class SmallPMap<K, V> implements CustomPMap<K, V> {\npublic static <K, V> SmallPMap<K, V> createS(Iterable<K> keys, Iterable<V> values) {\nreturn create(\n- StreamUtils.toStream(keys).toArray(Object[]::new),\n- StreamUtils.toStream(values).toArray(Object[]::new));\n+ StreamUtils.INSTANCE.toStream(keys).toArray(Object[]::new),\n+ StreamUtils.INSTANCE.toStream(values).toArray(Object[]::new));\n}\n@Override\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -68,9 +68,9 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nval rightAppliedOps: MutableList<IAppliedOperation> = ArrayList()\nval appliedVersionIds: TLongSet = TLongHashSet()\nwhile (!leftHistory.isEmpty() || !rightHistory.isEmpty()) {\n- val useLeft = rightHistory.isEmpty() || !leftHistory.isEmpty() && StreamUtils.last(leftHistory).id < StreamUtils.last(rightHistory).id\n+ val useLeft = rightHistory.isEmpty() || !leftHistory.isEmpty() && StreamUtils.last(leftHistory)!!.id < StreamUtils.last(rightHistory)!!.id\nval versionToApply = StreamUtils.removeLast(if (useLeft) leftHistory else rightHistory)\n- if (appliedVersionIds.contains(versionToApply.id)) {\n+ if (appliedVersionIds.contains(versionToApply!!.id)) {\ncontinue\n}\nappliedVersionIds.add(versionToApply.id)\n@@ -120,7 +120,7 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n* @param toVersionExclusive The oldest version\n* @return Newest version first\n*/\n- protected fun getHistory(fromVersion: String, toVersionExclusive: String?): List<CLVersion> {\n+ protected fun getHistory(fromVersion: String, toVersionExclusive: String?): MutableList<CLVersion> {\nval history: MutableList<CLVersion> = ArrayList()\nif (fromVersion == toVersionExclusive) {\nreturn history\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert ContextValue and StreamUtils
426,504
01.08.2020 12:21:25
-7,200
4fa7980b96b6c27e9f95459ee419c57ad4817220
convert a few interfaces
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IBranch.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import java.util.function.Supplier;\n-\n-public interface IBranch {\n- void runRead(Runnable runnable);\n- <T> T computeRead(Supplier<T> computable);\n- void runWrite(Runnable runnable);\n- <T> T computeWrite(Supplier<T> computable);\n-\n- boolean canRead();\n- boolean canWrite();\n-\n- ITransaction getTransaction();\n- IReadTransaction getReadTransaction();\n- IWriteTransaction getWriteTransaction();\n-\n- void addListener(IBranchListener l);\n- void removeListener(IBranchListener l);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IBranch.kt", "diff": "+package org.modelix.model.api\n+\n+import java.util.function.Supplier\n+\n+interface IBranch {\n+ fun runRead(runnable: Runnable?)\n+ fun <T> computeRead(computable: Supplier<T>?): T\n+ fun runWrite(runnable: Runnable?)\n+ fun <T> computeWrite(computable: Supplier<T>?): T\n+ fun canRead(): Boolean\n+ fun canWrite(): Boolean\n+ val transaction: ITransaction?\n+ val readTransaction: IReadTransaction?\n+ val writeTransaction: IWriteTransaction?\n+ fun addListener(l: IBranchListener?)\n+ fun removeListener(l: IBranchListener?)\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IBranchListener.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IBranchListener {\n- void treeChanged(ITree oldTree, ITree newTree);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IBranchListener.kt", "diff": "+package org.modelix.model.api\n+\n+interface IBranchListener {\n+ fun treeChanged(oldTree: ITree?, newTree: ITree?)\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IChildLink.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IChildLink {\n- String getName();\n- boolean isMultiple();\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IChildLink.kt", "diff": "+package org.modelix.model.api\n+\n+interface IChildLink {\n+ val name: String?\n+ val isMultiple: Boolean\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IConcept.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IConcept {\n- boolean isSubconceptOf(IConcept superConcept);\n- boolean isExactly(IConcept concept);\n-\n- Iterable<IProperty> getProperties();\n- Iterable<IChildLink> getChildLinks();\n- Iterable<IReferenceLink> getReferenceLinks();\n-\n- IProperty getProperty(String name);\n- IChildLink getChildLink(String name);\n- IReferenceLink getReferenceLink(String name);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IConcept.kt", "diff": "+package org.modelix.model.api\n+\n+interface IConcept {\n+ fun isSubconceptOf(superConcept: IConcept?): Boolean\n+ fun isExactly(concept: IConcept?): Boolean\n+ val properties: Iterable<IProperty?>?\n+ val childLinks: Iterable<IChildLink?>?\n+ val referenceLinks: Iterable<IReferenceLink?>?\n+ fun getProperty(name: String?): IProperty?\n+ fun getChildLink(name: String?): IChildLink?\n+ fun getReferenceLink(name: String?): IReferenceLink?\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -62,7 +62,7 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n}\n// A small number of changes may be faster to compute locally.\n}\n- branch.runWrite {\n+ branch.runWrite(Runnable {\nval t = branch.writeTransaction\nval leftAppliedOps: MutableList<IAppliedOperation> = ArrayList()\nval rightAppliedOps: MutableList<IAppliedOperation> = ArrayList()\n@@ -92,13 +92,13 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nversionToApply.id,\nversionToApply.time,\nversionToApply.author,\n- (t.tree as CLTree).hash,\n+ (t!!.tree as CLTree).hash,\nif (mergedVersion.value != null) mergedVersion.value.hash else versionToApply.previousHash,\noperationsToApply.toTypedArray(),\nstoreCache\n)\n}\n- }\n+ })\nif (mergedVersion.value == null) {\nthrow RuntimeException(\"Failed to merge $leftVersionHash and $rightVersionHash\")\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert a few interfaces
426,504
01.08.2020 12:22:28
-7,200
d186b5ec2d3da1539709f1246246090b083d93ba
convert more interfaces
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IIdGenerator.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IIdGenerator {\n- long generate();\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IIdGenerator.kt", "diff": "+package org.modelix.model.api\n+\n+interface IIdGenerator {\n+ fun generate(): Long\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/INode.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.jetbrains.annotations.Nullable;\n-\n-import java.util.stream.Stream;\n-\n-public interface INode {\n- boolean isValid();\n- INodeReference getReference();\n-\n- IConcept getConcept();\n- String getRoleInParent();\n- INode getParent();\n-\n- Stream<INode> getChildren(String role);\n- Stream<INode> getAllChildren();\n- void addChild(String role, int index, INode node);\n- INode addNewChild(String role, int index, @Nullable IConcept concept);\n- void removeChild(INode child);\n-\n- INode getReferenceTarget(String role);\n- void setReferenceTarget(String role, INode target);\n-\n- String getPropertyValue(String role);\n- void setPropertyValue(String role, String value);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/INode.kt", "diff": "+package org.modelix.model.api\n+\n+import java.util.stream.Stream\n+\n+interface INode {\n+ val isValid: Boolean\n+ val reference: INodeReference?\n+ val concept: IConcept?\n+ val roleInParent: String?\n+ val parent: INode?\n+ fun getChildren(role: String?): Stream<INode?>?\n+ val allChildren: Stream<INode?>?\n+ fun addChild(role: String?, index: Int, node: INode?)\n+ fun addNewChild(role: String?, index: Int, concept: IConcept?): INode?\n+ fun removeChild(child: INode?)\n+ fun getReferenceTarget(role: String?): INode?\n+ fun setReferenceTarget(role: String?, target: INode?)\n+ fun getPropertyValue(role: String?): String?\n+ fun setPropertyValue(role: String?, value: String?)\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/INodeReference.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.jetbrains.annotations.Nullable;\n-\n-/**\n- * The relation between an INodeReference and an INode is n to 1.\n- * Two INodeReferences that are not equal can resolve to the same INode.\n- */\n-public interface INodeReference {\n- @Nullable\n- INode resolveNode(INodeResolveContext context);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/INodeReference.kt", "diff": "+package org.modelix.model.api\n+\n+/**\n+ * The relation between an INodeReference and an INode is n to 1.\n+ * Two INodeReferences that are not equal can resolve to the same INode.\n+ */\n+interface INodeReference {\n+ fun resolveNode(context: INodeResolveContext?): INode?\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/INodeResolveContext.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.modelix.model.util.ContextValue;\n-\n-public interface INodeResolveContext {\n- ContextValue<INodeResolveContext> CONTEXT_VALUE = new ContextValue<>();\n- INode resolve(INodeReference ref);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/INodeResolveContext.kt", "diff": "+package org.modelix.model.api\n+\n+import org.modelix.model.util.ContextValue\n+\n+interface INodeResolveContext {\n+ fun resolve(ref: INodeReference?): INode?\n+\n+ companion object {\n+ @JvmField\n+ val CONTEXT_VALUE = ContextValue<INodeResolveContext>()\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IProperty.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IProperty {\n-\n- String getName();\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IProperty.kt", "diff": "+package org.modelix.model.api\n+\n+interface IProperty {\n+ val name: String?\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IReadTransaction.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IReadTransaction extends ITransaction {\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IReadTransaction.kt", "diff": "+package org.modelix.model.api\n+\n+interface IReadTransaction : ITransaction\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert more interfaces
426,504
01.08.2020 12:24:15
-7,200
16d065f600ffeba0c2c7f1870bda09514c92cdf1
complete conversion of interfaces in api package
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IReferenceLink.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IReferenceLink {\n- String getName();\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IReferenceLink.kt", "diff": "+package org.modelix.model.api\n+\n+interface IReferenceLink {\n+ val name: String?\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/ITransaction.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import java.util.stream.LongStream;\n-\n-public interface ITransaction {\n- IBranch getBranch();\n- ITree getTree();\n-\n- boolean containsNode(long nodeId);\n- IConcept getConcept(long nodeId);\n- long getParent(long nodeId);\n- String getRole(long nodeId);\n- String getProperty(long nodeId, String role);\n- INodeReference getReferenceTarget(long sourceId, String role);\n- LongStream getChildren(long parentId, String role);\n- LongStream getAllChildren(long parentId);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/ITransaction.kt", "diff": "+package org.modelix.model.api\n+\n+import java.util.stream.LongStream\n+\n+interface ITransaction {\n+ val branch: IBranch?\n+ val tree: ITree?\n+ fun containsNode(nodeId: Long): Boolean\n+ fun getConcept(nodeId: Long): IConcept?\n+ fun getParent(nodeId: Long): Long\n+ fun getRole(nodeId: Long): String?\n+ fun getProperty(nodeId: Long, role: String?): String?\n+ fun getReferenceTarget(sourceId: Long, role: String?): INodeReference?\n+ fun getChildren(parentId: Long, role: String?): LongStream?\n+ fun getAllChildren(parentId: Long): LongStream?\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/ITree.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import java.util.stream.LongStream;\n-\n-public interface ITree {\n- public static final long ROOT_ID = 1L;\n- public static final String DETACHED_NODES_ROLE = \"detached\";\n-\n- void visitChanges(ITree oldVersion, ITreeChangeVisitor visitor);\n- boolean containsNode(long nodeId);\n- String getProperty(long nodeId, String role);\n- LongStream getChildren(long parentId, String role);\n-\n- IConcept getConcept(long nodeId);\n-\n- long getParent(long nodeId);\n-\n- String getRole(long nodeId);\n-\n- ITree setProperty(long nodeId, String role, String value);\n-\n- INodeReference getReferenceTarget(long sourceId, String role);\n-\n- ITree setReferenceTarget(long sourceId, String role, INodeReference target);\n-\n- Iterable<String> getReferenceRoles(long sourceId);\n-\n- Iterable<String> getPropertyRoles(long sourceId);\n-\n- Iterable<String> getChildRoles(long sourceId);\n-\n- LongStream getAllChildren(long parentId);\n-\n- ITree moveChild(long newParentId, String newRole, int newIndex, long childId);\n-\n- ITree addNewChild(long parentId, String role, int index, long childId, IConcept concept);\n- ITree addNewChildren(long parentId, String role, int index, long[] newIds, IConcept[] concepts);\n-\n- ITree deleteNode(long nodeId);\n- ITree deleteNodes(long[] nodeIds);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/ITree.kt", "diff": "+package org.modelix.model.api\n+\n+import java.util.stream.LongStream\n+\n+interface ITree {\n+ fun visitChanges(oldVersion: ITree?, visitor: ITreeChangeVisitor?)\n+ fun containsNode(nodeId: Long): Boolean\n+ fun getProperty(nodeId: Long, role: String?): String?\n+ fun getChildren(parentId: Long, role: String?): LongStream?\n+ fun getConcept(nodeId: Long): IConcept?\n+ fun getParent(nodeId: Long): Long\n+ fun getRole(nodeId: Long): String?\n+ fun setProperty(nodeId: Long, role: String?, value: String?): ITree?\n+ fun getReferenceTarget(sourceId: Long, role: String?): INodeReference?\n+ fun setReferenceTarget(sourceId: Long, role: String?, target: INodeReference?): ITree?\n+ fun getReferenceRoles(sourceId: Long): Iterable<String?>?\n+ fun getPropertyRoles(sourceId: Long): Iterable<String?>?\n+ fun getChildRoles(sourceId: Long): Iterable<String?>?\n+ fun getAllChildren(parentId: Long): LongStream?\n+ fun moveChild(newParentId: Long, newRole: String?, newIndex: Int, childId: Long): ITree?\n+ fun addNewChild(parentId: Long, role: String?, index: Int, childId: Long, concept: IConcept?): ITree?\n+ fun addNewChildren(parentId: Long, role: String?, index: Int, newIds: LongArray?, concepts: Array<IConcept?>?): ITree?\n+ fun deleteNode(nodeId: Long): ITree?\n+ fun deleteNodes(nodeIds: LongArray?): ITree?\n+\n+ companion object {\n+ const val ROOT_ID = 1L\n+ const val DETACHED_NODES_ROLE = \"detached\"\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/ITreeChangeVisitor.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface ITreeChangeVisitor {\n- void containmentChanged(long nodeId);\n- void childrenChanged(long nodeId, String role);\n- void referenceChanged(long nodeId, String role);\n- void propertyChanged(long nodeId, String role);\n- void userObjectChanged(long nodeId, Object key);\n- void nodeRemoved(long nodeId);\n- void nodeAdded(long nodeId);\n- void nodeLoaded(long nodeId);\n- void nodeUnloaded(long nodeId);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/ITreeChangeVisitor.kt", "diff": "+package org.modelix.model.api\n+\n+interface ITreeChangeVisitor {\n+ fun containmentChanged(nodeId: Long)\n+ fun childrenChanged(nodeId: Long, role: String?)\n+ fun referenceChanged(nodeId: Long, role: String?)\n+ fun propertyChanged(nodeId: Long, role: String?)\n+ fun userObjectChanged(nodeId: Long, key: Any?)\n+ fun nodeRemoved(nodeId: Long)\n+ fun nodeAdded(nodeId: Long)\n+ fun nodeLoaded(nodeId: Long)\n+ fun nodeUnloaded(nodeId: Long)\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/IWriteTransaction.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public interface IWriteTransaction extends ITransaction {\n- void setProperty(long nodeId, String role, String value);\n- void setReferenceTarget(long sourceId, String role, INodeReference target);\n- void moveChild(long newParentId, String newRole, int newIndex, long childId);\n- long addNewChild(long parentId, String role, int index, IConcept concept);\n- void addNewChild(long parentId, String role, int index, long childId, IConcept concept);\n- void deleteNode(long nodeId);\n-\n- void setTree(ITree tree);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/IWriteTransaction.kt", "diff": "+package org.modelix.model.api\n+\n+interface IWriteTransaction : ITransaction {\n+ fun setProperty(nodeId: Long, role: String?, value: String?)\n+ fun setReferenceTarget(sourceId: Long, role: String?, target: INodeReference?)\n+ fun moveChild(newParentId: Long, newRole: String?, newIndex: Int, childId: Long)\n+ fun addNewChild(parentId: Long, role: String?, index: Int, concept: IConcept?): Long\n+ fun addNewChild(parentId: Long, role: String?, index: Int, childId: Long, concept: IConcept?)\n+ fun deleteNode(nodeId: Long)\n+ fun setTree(tree: ITree?)\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
complete conversion of interfaces in api package
426,504
01.08.2020 12:25:58
-7,200
18259b3c5302019df1c18ff08e69009a252a5cc9
migrate interfaces in client package
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/IIndirectBranch.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.api.IBranch;\n-import org.modelix.model.api.IBranchListener;\n-\n-public interface IIndirectBranch {\n- IBranch getBranch();\n- void addListener(IBranchListener l);\n- void removeListener(IBranchListener l);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/IIndirectBranch.kt", "diff": "+package org.modelix.model.client\n+\n+import org.modelix.model.api.IBranch\n+import org.modelix.model.api.IBranchListener\n+\n+interface IIndirectBranch {\n+ val branch: IBranch?\n+ fun addListener(l: IBranchListener?)\n+ fun removeListener(l: IBranchListener?)\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/IModelClient.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.IKeyValueStore;\n-import org.modelix.model.api.IIdGenerator;\n-import org.modelix.model.lazy.IDeserializingKeyValueStore;\n-\n-public interface IModelClient extends IKeyValueStore {\n- int getClientId();\n- IIdGenerator getIdGenerator();\n- IDeserializingKeyValueStore getStoreCache();\n- IKeyValueStore getAsyncStore();\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/IModelClient.kt", "diff": "+package org.modelix.model.client\n+\n+import org.modelix.model.IKeyValueStore\n+import org.modelix.model.api.IIdGenerator\n+import org.modelix.model.lazy.IDeserializingKeyValueStore\n+\n+interface IModelClient : IKeyValueStore {\n+ val clientId: Int\n+ val idGenerator: IIdGenerator?\n+ val storeCache: IDeserializingKeyValueStore?\n+ val asyncStore: IKeyValueStore?\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate interfaces in client package
426,504
01.08.2020 12:32:42
-7,200
20379741f7fc5518a959b31d39738f512b1bd553
convert interfaces in package operations
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/IOperation.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IWriteTransaction;\n-\n-public interface IOperation {\n- IAppliedOperation apply(IWriteTransaction transaction);\n- /**\n- * The 'previous' operation is the one that is inserted before this operation\n- * in the history of operations applied to the model.\n- * 'this' operation was created for a version that doesn't have 'previous' applied and now\n- * 'this' needs to be replaced with an operation that applies the same intended change\n- * on a model that was modified by 'previous' in the mean time.\n- */\n- IOperation transform(IOperation previous);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/IOperation.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.modelix.model.api.IWriteTransaction\n+\n+interface IOperation {\n+ fun apply(transaction: IWriteTransaction?): IAppliedOperation?\n+\n+ /**\n+ * The 'previous' operation is the one that is inserted before this operation\n+ * in the history of operations applied to the model.\n+ * 'this' operation was created for a version that doesn't have 'previous' applied and now\n+ * 'this' needs to be replaced with an operation that applies the same intended change\n+ * on a model that was modified by 'previous' in the mean time.\n+ */\n+ fun transform(previous: IOperation?): IOperation?\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -83,9 +83,9 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nfor (op in operationsToApply) {\nval appliedOp = op.apply(t)\nif (useLeft) {\n- leftAppliedOps.add(appliedOp)\n+ leftAppliedOps.add(appliedOp!!)\n} else {\n- rightAppliedOps.add(appliedOp)\n+ rightAppliedOps.add(appliedOp!!)\n}\n}\nmergedVersion.value = CLVersion(\n@@ -108,7 +108,7 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nprotected fun transformOperation(opToTransform: IOperation, previousOps: Iterable<IOperation?>): IOperation {\nvar result = opToTransform\nfor (previous in previousOps) {\n- result = result.transform(previous)\n+ result = result.transform(previous)!!\n}\nreturn result\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert interfaces in package operations
426,504
01.08.2020 12:33:38
-7,200
2cb9ced28ab8cfed746889585d1b7e3959ca9169
convert remaining interfaces under package operations
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/IAppliedOperation.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-public interface IAppliedOperation {\n- IOperation getOriginalOp();\n- IOperation invert();\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/IAppliedOperation.kt", "diff": "+package org.modelix.model.operations\n+\n+interface IAppliedOperation {\n+ val originalOp: IOperation?\n+ fun invert(): IOperation?\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/IModifiesChildrenOp.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-public interface IModifiesChildrenOp {\n- int adjustIndex(long parentId, String role, int index);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/IModifiesChildrenOp.kt", "diff": "+package org.modelix.model.operations\n+\n+interface IModifiesChildrenOp {\n+ fun adjustIndex(parentId: Long, role: String?, index: Int): Int\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert remaining interfaces under package operations
426,504
01.08.2020 12:35:38
-7,200
a361d66d11294c49d7198b1049b6d79fa27a31c7
converting DefaultIdGenerator
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/DefaultIdGenerator.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import java.util.concurrent.atomic.AtomicLong;\n-\n-public class DefaultIdGenerator implements IIdGenerator {\n- private static final DefaultIdGenerator INSTANCE = new DefaultIdGenerator();\n-\n- public static DefaultIdGenerator getInstance() {\n- return INSTANCE;\n- }\n-\n- protected final AtomicLong ID_SEQUENCE = new AtomicLong(Math.round(Math.abs(Math.random()) * 1000000000.0) * 1000000000L);\n-\n- private DefaultIdGenerator() {\n- }\n-\n- @Override\n- public long generate() {\n- return ID_SEQUENCE.incrementAndGet();\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/DefaultIdGenerator.kt", "diff": "+package org.modelix.model.api\n+\n+import java.util.concurrent.atomic.AtomicLong\n+\n+class DefaultIdGenerator private constructor() : IIdGenerator {\n+ protected val ID_SEQUENCE = AtomicLong(Math.round(Math.abs(Math.random()) * 1000000000.0) * 1000000000L)\n+ override fun generate(): Long {\n+ return ID_SEQUENCE.incrementAndGet()\n+ }\n+\n+ companion object {\n+ val instance = DefaultIdGenerator()\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/api/PBranch.java", "new_path": "model-client/src/main/java/org/modelix/model/api/PBranch.java", "diff": "@@ -21,7 +21,7 @@ public class PBranch implements IBranch {\nprivate IIdGenerator idGenerator;\npublic PBranch(ITree initialTree) {\n- this(initialTree, DefaultIdGenerator.getInstance());\n+ this(initialTree, DefaultIdGenerator.Companion.getInstance());\n}\npublic PBranch(ITree initialTree, @Nullable IIdGenerator idGenerator) {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
converting DefaultIdGenerator
426,504
01.08.2020 12:36:32
-7,200
f7e2bdf3cca69b3c40ade1fc990f044dd9e20ade
convert PNodeReference
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/PNodeReference.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.jetbrains.annotations.Nullable;\n-\n-public class PNodeReference implements INodeReference {\n- private long id;\n-\n- public PNodeReference(long id) {\n- this.id = id;\n- }\n-\n- public long getId() {\n- return id;\n- }\n-\n- @Nullable\n- @Override\n- public INode resolveNode(INodeResolveContext context) {\n- if (context instanceof PNodeResolveContext) {\n- return new PNodeAdapter(id, ((PNodeResolveContext) context).getBranch());\n- } else {\n- return context.resolve(this);\n- }\n- }\n-\n- @Override\n- public boolean equals(Object o) {\n- if (this == o) {\n- return true;\n- }\n- if (o == null || this.getClass() != o.getClass()) {\n- return false;\n- }\n-\n- PNodeReference that = (PNodeReference) o;\n- if (id != that.id) {\n- return false;\n- }\n-\n- return true;\n- }\n-\n- @Override\n- public int hashCode() {\n- int result = 0;\n- result = 31 * result + (int) (id ^ (id >> 32));\n- return result;\n- }\n-\n- @Override\n- public String toString() {\n- return \"PNodeReference{\" + \"id=\" + id + \"}\";\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/PNodeReference.kt", "diff": "+package org.modelix.model.api\n+\n+class PNodeReference(val id: Long) : INodeReference {\n+\n+ override fun resolveNode(context: INodeResolveContext?): INode? {\n+ return if (context is PNodeResolveContext) {\n+ PNodeAdapter(id, context.branch)\n+ } else {\n+ context!!.resolve(this)\n+ }\n+ }\n+\n+ override fun equals(o: Any?): Boolean {\n+ if (this === o) {\n+ return true\n+ }\n+ if (o == null || this.javaClass != o.javaClass) {\n+ return false\n+ }\n+ val that = o as PNodeReference\n+ return if (id != that.id) {\n+ false\n+ } else true\n+ }\n+\n+ override fun hashCode(): Int {\n+ var result = 0\n+ result = 31 * result + (id xor (id shr 32)).toInt()\n+ return result\n+ }\n+\n+ override fun toString(): String {\n+ return \"PNodeReference{id=$id}\"\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert PNodeReference
426,504
01.08.2020 12:41:04
-7,200
2ae80770a3396c0e5c26314bb70813b8d4fef917
convert transaction classes
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/ReadTransaction.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.jetbrains.annotations.NotNull;\n-\n-public class ReadTransaction extends Transaction implements IReadTransaction {\n- private final ITree tree;\n-\n- public ReadTransaction(@NotNull ITree tree, IBranch branch) {\n- super(branch);\n- this.tree = tree;\n- }\n- @Override\n- public ITree getTree() {\n- return tree;\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/ReadTransaction.kt", "diff": "+package org.modelix.model.api\n+\n+class ReadTransaction(override var tree: ITree?, branch: IBranch?) : Transaction(branch), IReadTransaction\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/Transaction.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import java.util.stream.LongStream;\n-\n-public abstract class Transaction implements ITransaction {\n- protected final IBranch branch;\n-\n- public Transaction(IBranch branch) {\n- this.branch = branch;\n- }\n-\n- @Override\n- public IBranch getBranch() {\n- return branch;\n- }\n-\n- @Override\n- public boolean containsNode(long nodeId) {\n- return getTree().containsNode(nodeId);\n- }\n-\n- @Override\n- public IConcept getConcept(long nodeId) {\n- return getTree().getConcept(nodeId);\n- }\n-\n- @Override\n- public long getParent(long nodeId) {\n- return getTree().getParent(nodeId);\n- }\n-\n- @Override\n- public String getRole(long nodeId) {\n- return getTree().getRole(nodeId);\n- }\n-\n- @Override\n- public String getProperty(long nodeId, String role) {\n- return getTree().getProperty(nodeId, role);\n- }\n-\n- @Override\n- public INodeReference getReferenceTarget(long sourceId, String role) {\n- return getTree().getReferenceTarget(sourceId, role);\n- }\n-\n- @Override\n- public LongStream getChildren(long parentId, String role) {\n- return getTree().getChildren(parentId, role);\n- }\n-\n- @Override\n- public LongStream getAllChildren(long parentId) {\n- return getTree().getAllChildren(parentId);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/Transaction.kt", "diff": "+package org.modelix.model.api\n+\n+import java.util.stream.LongStream\n+\n+abstract class Transaction(override val branch: IBranch?) : ITransaction {\n+\n+ override fun containsNode(nodeId: Long): Boolean {\n+ return tree!!.containsNode(nodeId)\n+ }\n+\n+ override fun getConcept(nodeId: Long): IConcept? {\n+ return tree!!.getConcept(nodeId)\n+ }\n+\n+ override fun getParent(nodeId: Long): Long {\n+ return tree!!.getParent(nodeId)\n+ }\n+\n+ override fun getRole(nodeId: Long): String? {\n+ return tree!!.getRole(nodeId)\n+ }\n+\n+ override fun getProperty(nodeId: Long, role: String?): String? {\n+ return tree!!.getProperty(nodeId, role)\n+ }\n+\n+ override fun getReferenceTarget(sourceId: Long, role: String?): INodeReference? {\n+ return tree!!.getReferenceTarget(sourceId, role)\n+ }\n+\n+ override fun getChildren(parentId: Long, role: String?): LongStream? {\n+ return tree!!.getChildren(parentId, role)\n+ }\n+\n+ override fun getAllChildren(parentId: Long): LongStream? {\n+ return tree!!.getAllChildren(parentId)\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/WriteTransaction.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.jetbrains.annotations.NotNull;\n-\n-public class WriteTransaction extends Transaction implements IWriteTransaction {\n- protected ITree tree;\n- private boolean closed = false;\n- protected IIdGenerator idGenerator;\n-\n- public WriteTransaction(@NotNull ITree tree, IBranch branch, IIdGenerator idGenerator) {\n- super(branch);\n- this.tree = tree;\n- this.idGenerator = idGenerator;\n- }\n-\n- public void close() {\n- closed = true;\n- }\n-\n- protected void checkNotClosed() {\n- if (closed) {\n- throw new IllegalStateException(\"Transaction is already closed\");\n- }\n- }\n-\n- @Override\n- public ITree getTree() {\n- return tree;\n- }\n-\n- @Override\n- public void setTree(ITree newTree) {\n- checkNotClosed();\n- this.tree = newTree;\n- }\n-\n- @Override\n- public void setProperty(long nodeId, String role, String value) {\n- checkNotClosed();\n- tree = getTree().setProperty(nodeId, role, value);\n- }\n-\n- @Override\n- public void setReferenceTarget(long sourceId, String role, INodeReference target) {\n- checkNotClosed();\n- tree = getTree().setReferenceTarget(sourceId, role, target);\n- }\n-\n- @Override\n- public void moveChild(long newParentId, String newRole, int newIndex, long childId) {\n- checkNotClosed();\n- tree = getTree().moveChild(newParentId, newRole, newIndex, childId);\n- }\n-\n- @Override\n- public long addNewChild(long parentId, String role, int index, IConcept concept) {\n- checkNotClosed();\n- long newId = idGenerator.generate();\n- addNewChild(parentId, role, index, newId, concept);\n- return newId;\n- }\n-\n- @Override\n- public void addNewChild(long parentId, String role, int index, long childId, IConcept concept) {\n- checkNotClosed();\n- tree = getTree().addNewChild(parentId, role, index, childId, concept);\n- }\n-\n- @Override\n- public void deleteNode(long nodeId) {\n- checkNotClosed();\n- getTree().getAllChildren(nodeId).forEach(this::deleteNode);\n- tree = getTree().deleteNode(nodeId);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/WriteTransaction.kt", "diff": "+package org.modelix.model.api\n+\n+class WriteTransaction(_tree: ITree?, branch: IBranch?, idGenerator: IIdGenerator) : Transaction(branch), IWriteTransaction {\n+ override var tree: ITree? = _tree\n+ set(value) {\n+ checkNotClosed()\n+ tree = value\n+ }\n+ private var closed = false\n+ protected var idGenerator: IIdGenerator\n+ fun close() {\n+ closed = true\n+ }\n+\n+ protected fun checkNotClosed() {\n+ check(!closed) { \"Transaction is already closed\" }\n+ }\n+\n+// override fun getTree(): ITree? {\n+// return tree\n+// }\n+//\n+// override fun setTree(newTree: ITree?) {\n+// checkNotClosed()\n+// tree = newTree\n+// }\n+\n+ override fun setProperty(nodeId: Long, role: String?, value: String?) {\n+ checkNotClosed()\n+ tree = tree!!.setProperty(nodeId, role, value)\n+ }\n+\n+ override fun setReferenceTarget(sourceId: Long, role: String?, target: INodeReference?) {\n+ checkNotClosed()\n+ tree = tree!!.setReferenceTarget(sourceId, role, target)\n+ }\n+\n+ override fun moveChild(newParentId: Long, newRole: String?, newIndex: Int, childId: Long) {\n+ checkNotClosed()\n+ tree = tree!!.moveChild(newParentId, newRole, newIndex, childId)\n+ }\n+\n+ override fun addNewChild(parentId: Long, role: String?, index: Int, concept: IConcept?): Long {\n+ checkNotClosed()\n+ val newId = idGenerator.generate()\n+ addNewChild(parentId, role, index, newId, concept)\n+ return newId\n+ }\n+\n+ override fun addNewChild(parentId: Long, role: String?, index: Int, childId: Long, concept: IConcept?) {\n+ checkNotClosed()\n+ tree = tree!!.addNewChild(parentId, role, index, childId, concept)\n+ }\n+\n+ override fun deleteNode(nodeId: Long) {\n+ checkNotClosed()\n+ tree!!.getAllChildren(nodeId)!!.forEach { nodeId: Long -> deleteNode(nodeId) }\n+ tree = tree!!.deleteNode(nodeId)\n+ }\n+\n+ init {\n+ this.tree = tree\n+ this.idGenerator = idGenerator\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/api/ITransaction.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/api/ITransaction.kt", "diff": "@@ -4,7 +4,7 @@ import java.util.stream.LongStream\ninterface ITransaction {\nval branch: IBranch?\n- val tree: ITree?\n+ var tree: ITree?\nfun containsNode(nodeId: Long): Boolean\nfun getConcept(nodeId: Long): IConcept?\nfun getParent(nodeId: Long): Long\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/api/IWriteTransaction.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/api/IWriteTransaction.kt", "diff": "@@ -7,5 +7,5 @@ interface IWriteTransaction : ITransaction {\nfun addNewChild(parentId: Long, role: String?, index: Int, concept: IConcept?): Long\nfun addNewChild(parentId: Long, role: String?, index: Int, childId: Long, concept: IConcept?)\nfun deleteNode(nodeId: Long)\n- fun setTree(tree: ITree?)\n+ //fun setTree(tree: ITree?)\n}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert transaction classes
426,504
01.08.2020 12:41:44
-7,200
e9eee5f59aeab1fd9dfd78d0e4db3e82dbb2becb
convert PNodeResolveContext
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/PNodeResolveContext.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-public class PNodeResolveContext implements INodeResolveContext {\n- private IBranch branch;\n-\n- public PNodeResolveContext(IBranch branch) {\n- this.branch = branch;\n- }\n-\n- public IBranch getBranch() {\n- return branch;\n- }\n-\n- @Override\n- public INode resolve(INodeReference ref) {\n- if (ref instanceof PNodeReference) {\n- return new PNodeAdapter(((PNodeReference) ref).getId(), branch);\n- } else {\n- return null;\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/PNodeResolveContext.kt", "diff": "+package org.modelix.model.api\n+\n+class PNodeResolveContext(val branch: IBranch) : INodeResolveContext {\n+\n+ override fun resolve(ref: INodeReference?): INode? {\n+ return if (ref is PNodeReference) {\n+ PNodeAdapter(ref.id, branch)\n+ } else {\n+ null\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert PNodeResolveContext
426,504
01.08.2020 12:44:29
-7,200
36565697689a7e8473fe032b02000055f6bf1d51
convert PNodeAdapter
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/PNodeAdapter.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.jetbrains.annotations.Nullable;\n-\n-import java.util.Objects;\n-import java.util.stream.Stream;\n-\n-public class PNodeAdapter implements INode {\n- public static INode wrap(long id, IBranch branch) {\n- return (id == 0 ? null : new PNodeAdapter(id, branch));\n- }\n-\n- private IBranch branch;\n- private long nodeId;\n-\n- public PNodeAdapter(long nodeId, IBranch branch) {\n- this.nodeId = nodeId;\n- this.branch = branch;\n- notifyAccess();\n- }\n-\n- public IBranch getBranch() {\n- return branch;\n- }\n-\n- public long getNodeId() {\n- return nodeId;\n- }\n-\n- public INode wrap(long id) {\n- return wrap(id, branch);\n- }\n-\n- protected long unwrap(INode node) {\n- if (node == null) {\n- return 0;\n- }\n- if (!((node instanceof PNodeAdapter))) {\n- throw new RuntimeException(\"Not a \" + PNodeAdapter.class.getSimpleName() + \": \" + node);\n- }\n- PNodeAdapter adapter = ((PNodeAdapter) node);\n- if (!(Objects.equals(adapter.branch, branch))) {\n- throw new RuntimeException(\"Node belongs to a different branch. Expected \" + branch + \" but was \" + adapter.branch);\n- }\n- return adapter.nodeId;\n- }\n-\n- protected void notifyAccess() {\n-// DependencyBroadcaster.INSTANCE.dependencyAccessed(new PNodeDependency(branch, nodeId));\n- }\n-\n- @Override\n- public void addChild(String role, int index, INode node) {\n- throw new UnsupportedOperationException(\"Not implemented\");\n- }\n- @Override\n- public INode addNewChild(String role, int index, @Nullable IConcept concept) {\n- return wrap(branch.getWriteTransaction().addNewChild(nodeId, role, index, concept));\n- }\n- @Override\n- public Stream<INode> getAllChildren() {\n- notifyAccess();\n- return branch.getTransaction().getAllChildren(nodeId).mapToObj(this::wrap);\n- }\n- @Override\n- public Stream<INode> getChildren(String role) {\n- notifyAccess();\n- return branch.getTransaction().getChildren(nodeId, role).mapToObj(this::wrap);\n- }\n- @Override\n- public IConcept getConcept() {\n- notifyAccess();\n- return branch.computeRead(() -> branch.getTransaction().getConcept(nodeId));\n- }\n- @Override\n- public INode getParent() {\n- notifyAccess();\n- long parent = branch.getTransaction().getParent(nodeId);\n- if (parent == 0 || parent == ITree.ROOT_ID) {\n- return null;\n- }\n- return wrap(parent);\n- }\n- @Override\n- public String getPropertyValue(String role) {\n- notifyAccess();\n- return branch.getTransaction().getProperty(nodeId, role);\n- }\n- @Override\n- public INodeReference getReference() {\n- return new PNodeReference(nodeId);\n- }\n- @Override\n- public INode getReferenceTarget(String role) {\n- notifyAccess();\n- INodeReference targetRef = branch.getTransaction().getReferenceTarget(nodeId, role);\n- if (targetRef instanceof PNodeReference) {\n- return targetRef.resolveNode(new PNodeResolveContext(branch));\n- }\n- INodeResolveContext context = INodeResolveContext.CONTEXT_VALUE.getValue();\n- if (context == null) {\n- throw new RuntimeException(INodeResolveContext.class.getSimpleName() + \" not available\");\n- }\n- return (targetRef == null ? null : targetRef.resolveNode(context));\n-\n- }\n- @Override\n- public String getRoleInParent() {\n- notifyAccess();\n- return branch.getTransaction().getRole(nodeId);\n- }\n- @Override\n- public boolean isValid() {\n- notifyAccess();\n- return branch.getTransaction().containsNode(nodeId);\n- }\n- @Override\n- public void removeChild(INode child) {\n- branch.getWriteTransaction().deleteNode(unwrap(child));\n- }\n- @Override\n- public void setPropertyValue(String role, String value) {\n- branch.getWriteTransaction().setProperty(nodeId, role, value);\n- }\n- @Override\n- public void setReferenceTarget(String role, INode target) {\n- branch.getWriteTransaction().setReferenceTarget(nodeId, role, (target == null ? null : target.getReference()));\n- }\n- public void setReferenceTarget(String role, INodeReference target) {\n- branch.getWriteTransaction().setReferenceTarget(nodeId, role, target);\n- }\n-\n- @Override\n- public boolean equals(Object o) {\n- if (this == o) {\n- return true;\n- }\n- if (o == null || this.getClass() != o.getClass()) {\n- return false;\n- }\n-\n- PNodeAdapter that = (PNodeAdapter) o;\n- if ((branch != null ? !(branch.equals(that.branch)) : that.branch != null)) {\n- return false;\n- }\n- if (nodeId != that.nodeId) {\n- return false;\n- }\n-\n- return true;\n- }\n-\n- @Override\n- public int hashCode() {\n- int result = 0;\n- result = 31 * result + ((branch != null ? ((Object) branch).hashCode() : 0));\n- result = 31 * result + (int) (nodeId ^ (nodeId >> 32));\n- return result;\n- }\n-\n- @Override\n- public String toString() {\n- IConcept concept = null;\n- try {\n- concept = branch.computeRead(() -> branch.getTransaction().getConcept(nodeId));\n- } catch (Exception ex) {\n- }\n- String str = \"PNode\" + nodeId;\n- if (concept != null) {\n- str += \"[\" + concept + \"]\";\n- }\n- return str;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/PNodeAdapter.kt", "diff": "+package org.modelix.model.api\n+\n+import org.modelix.model.api.INodeResolveContext\n+import java.util.function.Supplier\n+import java.util.stream.Stream\n+\n+class PNodeAdapter(val nodeId: Long, val branch: IBranch?) : INode {\n+\n+ protected fun unwrap(node: INode?): Long {\n+ if (node == null) {\n+ return 0\n+ }\n+ if (node !is PNodeAdapter) {\n+ throw RuntimeException(\"Not a \" + PNodeAdapter::class.java.simpleName + \": \" + node)\n+ }\n+ val adapter = node\n+ if (adapter.branch != branch) {\n+ throw RuntimeException(\"Node belongs to a different branch. Expected \" + branch + \" but was \" + adapter.branch)\n+ }\n+ return adapter.nodeId\n+ }\n+\n+ protected fun notifyAccess() {\n+// DependencyBroadcaster.INSTANCE.dependencyAccessed(new PNodeDependency(branch, nodeId));\n+ }\n+\n+ override fun addChild(role: String?, index: Int, node: INode?) {\n+ throw UnsupportedOperationException(\"Not implemented\")\n+ }\n+\n+ override fun addNewChild(role: String?, index: Int, concept: IConcept?): INode? {\n+ return wrap(branch!!.writeTransaction!!.addNewChild(nodeId, role, index, concept))\n+ }\n+\n+ override val allChildren: Stream<INode>\n+ get() {\n+ notifyAccess()\n+ return branch!!.transaction!!.getAllChildren(nodeId)!!.mapToObj { id: Long -> wrap(id) }\n+ }\n+\n+ override fun getChildren(role: String?): Stream<INode?>? {\n+ notifyAccess()\n+ return branch!!.transaction!!.getChildren(nodeId, role)!!.mapToObj { id: Long -> wrap(id) }\n+ }\n+\n+ override val concept: IConcept?\n+ get() {\n+ notifyAccess()\n+ return branch!!.computeRead(Supplier { branch.transaction!!.getConcept(nodeId) })\n+ }\n+\n+ override val parent: INode?\n+ get() {\n+ notifyAccess()\n+ val parent = branch!!.transaction!!.getParent(nodeId)\n+ return if (parent == 0L || parent == ITree.ROOT_ID) {\n+ null\n+ } else wrap(parent)\n+ }\n+\n+ override fun getPropertyValue(role: String?): String? {\n+ notifyAccess()\n+ return branch!!.transaction!!.getProperty(nodeId, role)\n+ }\n+\n+ override val reference: INodeReference\n+ get() = PNodeReference(nodeId)\n+\n+ override fun getReferenceTarget(role: String?): INode? {\n+ notifyAccess()\n+ val targetRef = branch!!.transaction!!.getReferenceTarget(nodeId, role)\n+ if (targetRef is PNodeReference) {\n+ return targetRef.resolveNode(PNodeResolveContext(branch))\n+ }\n+ val context = INodeResolveContext.CONTEXT_VALUE.getValue()\n+ ?: throw RuntimeException(INodeResolveContext::class.java.simpleName + \" not available\")\n+ return targetRef?.resolveNode(context)\n+ }\n+\n+ override val roleInParent: String?\n+ get() {\n+ notifyAccess()\n+ return branch!!.transaction!!.getRole(nodeId)\n+ }\n+\n+ override val isValid: Boolean\n+ get() {\n+ notifyAccess()\n+ return branch!!.transaction!!.containsNode(nodeId)\n+ }\n+\n+ override fun removeChild(child: INode?) {\n+ branch!!.writeTransaction!!.deleteNode(unwrap(child))\n+ }\n+\n+ override fun setPropertyValue(role: String?, value: String?) {\n+ branch!!.writeTransaction!!.setProperty(nodeId, role, value)\n+ }\n+\n+ override fun setReferenceTarget(role: String?, target: INode?) {\n+ branch!!.writeTransaction!!.setReferenceTarget(nodeId, role, target?.reference)\n+ }\n+\n+ fun setReferenceTarget(role: String?, target: INodeReference?) {\n+ branch!!.writeTransaction!!.setReferenceTarget(nodeId, role, target)\n+ }\n+\n+ override fun equals(o: Any?): Boolean {\n+ if (this === o) {\n+ return true\n+ }\n+ if (o == null || this.javaClass != o.javaClass) {\n+ return false\n+ }\n+ val that = o as PNodeAdapter\n+ if (if (branch != null) branch != that.branch else that.branch != null) {\n+ return false\n+ }\n+ return if (nodeId != that.nodeId) {\n+ false\n+ } else true\n+ }\n+\n+ override fun hashCode(): Int {\n+ var result = 0\n+ result = 31 * result + if (branch != null) (branch as Any).hashCode() else 0\n+ result = 31 * result + (nodeId xor (nodeId shr 32)).toInt()\n+ return result\n+ }\n+\n+ override fun toString(): String {\n+ var concept: IConcept? = null\n+ try {\n+ concept = branch!!.computeRead(Supplier { branch.transaction!!.getConcept(nodeId) })\n+ } catch (ex: Exception) {\n+ }\n+ var str = \"PNode$nodeId\"\n+ if (concept != null) {\n+ str += \"[$concept]\"\n+ }\n+ return str\n+ }\n+\n+ //companion object {\n+ @JvmOverloads\n+ fun wrap(id: Long, branch: IBranch? = this.branch): INode? {\n+ return if (id == 0L) null else PNodeAdapter(id, branch)\n+ }\n+ //}\n+\n+ init {\n+ notifyAccess()\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/api/INode.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/api/INode.kt", "diff": "@@ -9,7 +9,7 @@ interface INode {\nval roleInParent: String?\nval parent: INode?\nfun getChildren(role: String?): Stream<INode?>?\n- val allChildren: Stream<INode?>?\n+ val allChildren: Stream<INode>\nfun addChild(role: String?, index: Int, node: INode?)\nfun addNewChild(role: String?, index: Int, concept: IConcept?): INode?\nfun removeChild(child: INode?)\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert PNodeAdapter
426,504
01.08.2020 12:45:39
-7,200
c3dbe1a291da8f9e80325bbc56bc535da54f4d28
formatting Kotlin code
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/api/PNodeAdapter.kt", "new_path": "model-client/src/main/java/org/modelix/model/api/PNodeAdapter.kt", "diff": "package org.modelix.model.api\n-import org.modelix.model.api.INodeResolveContext\nimport java.util.function.Supplier\nimport java.util.stream.Stream\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/api/PNodeReference.kt", "new_path": "model-client/src/main/java/org/modelix/model/api/PNodeReference.kt", "diff": "@@ -32,5 +32,4 @@ class PNodeReference(val id: Long) : INodeReference {\noverride fun toString(): String {\nreturn \"PNodeReference{id=$id}\"\n}\n-\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/api/PNodeResolveContext.kt", "new_path": "model-client/src/main/java/org/modelix/model/api/PNodeResolveContext.kt", "diff": "@@ -9,5 +9,4 @@ class PNodeResolveContext(val branch: IBranch) : INodeResolveContext {\nnull\n}\n}\n-\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/api/Transaction.kt", "new_path": "model-client/src/main/java/org/modelix/model/api/Transaction.kt", "diff": "@@ -35,5 +35,4 @@ abstract class Transaction(override val branch: IBranch?) : ITransaction {\noverride fun getAllChildren(parentId: Long): LongStream? {\nreturn tree!!.getAllChildren(parentId)\n}\n-\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/util/ContextValue.kt", "new_path": "model-client/src/main/java/org/modelix/model/util/ContextValue.kt", "diff": "package org.modelix.model.util\n-import java.util.*\nimport java.util.function.Supplier\nclass ContextValue<E> {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/IKeyValueStore.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/IKeyValueStore.kt", "diff": "package org.modelix.model\n-\ninterface IKeyValueStore {\noperator fun get(key: String?): String?\nfun put(key: String?, value: String?)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -14,8 +14,10 @@ import org.modelix.model.operations.IAppliedOperation\nimport org.modelix.model.operations.IOperation\nimport org.modelix.model.persistent.CPVersion\nimport org.modelix.model.util.StreamUtils\n-import java.util.*\n+import java.util.Optional\nimport java.util.stream.Collectors\n+import kotlin.collections.ArrayList\n+import kotlin.collections.HashSet\nclass VersionMerger(private val storeCache: IDeserializingKeyValueStore, private val idGenerator: IIdGenerator) {\nprivate val mergeLock = Any()\n@@ -62,7 +64,8 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n}\n// A small number of changes may be faster to compute locally.\n}\n- branch.runWrite(Runnable {\n+ branch.runWrite(\n+ Runnable {\nval t = branch.writeTransaction\nval leftAppliedOps: MutableList<IAppliedOperation> = ArrayList()\nval rightAppliedOps: MutableList<IAppliedOperation> = ArrayList()\n@@ -98,7 +101,8 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nstoreCache\n)\n}\n- })\n+ }\n+ )\nif (mergedVersion.value == null) {\nthrow RuntimeException(\"Failed to merge $leftVersionHash and $rightVersionHash\")\n}\n@@ -185,5 +189,4 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nnull\n} else CLTree(version.treeHash, storeCache)\n}\n-\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
formatting Kotlin code
426,504
01.08.2020 12:48:47
-7,200
56129c862be9180a08819cec4f67f26b7d1e1105
convert NodeUtil
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/NodeUtil.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import java.util.stream.Stream;\n-\n-public class NodeUtil {\n- public static Stream<INode> getDescendants(INode node, boolean includeSelf) {\n- if (includeSelf) {\n- return Stream.concat(Stream.of(node), getDescendants(node, false));\n- } else {\n- return node.getAllChildren().flatMap(it -> getDescendants(it, true));\n- }\n- }\n-\n- public static INode getAncestor(final INode _this, IConcept concept, boolean includeSelf) {\n- if (_this == null) {\n- return null;\n- }\n- if (includeSelf && _this.getConcept().isSubconceptOf(concept)) {\n- return _this;\n- }\n- return getAncestor(_this.getParent(), concept, true);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/NodeUtil.kt", "diff": "+package org.modelix.model.api\n+\n+import java.util.stream.Stream\n+\n+object NodeUtil {\n+ fun getDescendants(node: INode, includeSelf: Boolean): Stream<INode?> {\n+ return if (includeSelf) {\n+ Stream.concat(Stream.of(node), getDescendants(node, false))\n+ } else {\n+ node.allChildren.flatMap { it: INode -> getDescendants(it, true) }\n+ }\n+ }\n+\n+ fun getAncestor(_this: INode?, concept: IConcept?, includeSelf: Boolean): INode? {\n+ if (_this == null) {\n+ return null\n+ }\n+ return if (includeSelf && _this.concept!!.isSubconceptOf(concept)) {\n+ _this\n+ } else getAncestor(_this.parent, concept, true)\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert NodeUtil
426,504
01.08.2020 12:49:33
-7,200
25821c3b6091cc48c92b589d45102388480aab39
convert PBranch
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/PBranch.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.modelix.model.util.ContextValue;\n-import org.modelix.model.util.pmap.COWArrays;\n-import org.apache.commons.lang3.mutable.MutableObject;\n-import org.apache.log4j.Level;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.jetbrains.annotations.Nullable;\n-\n-import java.util.function.Supplier;\n-\n-public class PBranch implements IBranch {\n- private static final Logger LOG = LogManager.getLogger(PBranch.class);\n- private volatile ITree tree;\n-\n- private final Object writeLock = new Object();\n- private final ContextValue<Transaction> contextTransactions = new ContextValue<Transaction>();\n- private IBranchListener[] listeners = new IBranchListener[0];\n- @Nullable\n- private IIdGenerator idGenerator;\n-\n- public PBranch(ITree initialTree) {\n- this(initialTree, DefaultIdGenerator.Companion.getInstance());\n- }\n-\n- public PBranch(ITree initialTree, @Nullable IIdGenerator idGenerator) {\n- this.tree = initialTree;\n- this.idGenerator = idGenerator;\n- }\n-\n- public void runWithTransaction(ITransaction transaction, Runnable runnable) {\n- contextTransactions.runWith((Transaction) transaction, runnable);\n- }\n-\n- @Override\n- public void runRead(Runnable runnable) {\n- Transaction prevTransaction = contextTransactions.getValue();\n- if (prevTransaction instanceof IReadTransaction) {\n- runnable.run();\n- } else {\n- ITree currentTree = (prevTransaction == null ? this.tree : prevTransaction.getTree());\n- ReadTransaction t = new ReadTransaction(currentTree, this);\n- contextTransactions.runWith(t, runnable);\n- }\n- }\n-\n- @Override\n- public void runWrite(Runnable runnable) {\n- synchronized (writeLock) {\n- Transaction prevTransaction = contextTransactions.getValue();\n- if (prevTransaction instanceof ReadTransaction) {\n- throw new IllegalStateException(\"Cannot run write from read\");\n- }\n-\n- WriteTransaction prevWrite = (WriteTransaction) prevTransaction;\n-\n- final ITree oldTree = (prevWrite == null ? tree : prevWrite.getTree());\n- WriteTransaction newWrite = new WriteTransaction(oldTree, this, idGenerator);\n- try {\n- contextTransactions.runWith(newWrite, runnable);\n- newWrite.close();\n- ITree newTree = newWrite.getTree();\n- if (prevWrite == null) {\n- tree = newTree;\n- notifyTreeChange(oldTree, newTree);\n- } else {\n- prevWrite.setTree(newTree);\n- }\n- } finally {\n- newWrite.close();\n- }\n- }\n- }\n-\n- @Override\n- public <T> T computeRead(final Supplier<T> computable) {\n- final MutableObject<T> result = new MutableObject<>();\n- runRead(() -> result.setValue(computable.get()));\n- return result.getValue();\n- }\n-\n- @Override\n- public <T> T computeWrite(final Supplier<T> computable) {\n- final MutableObject<T> result = new MutableObject<>();\n- runWrite(() -> result.setValue(computable.get()));\n- return result.getValue();\n- }\n-\n- @Override\n- public boolean canRead() {\n- return contextTransactions.getValue() != null;\n- }\n-\n- @Override\n- public boolean canWrite() {\n- return contextTransactions.getValue() instanceof IWriteTransaction;\n- }\n-\n- public Transaction getTransaction() {\n- Transaction t = contextTransactions.getValue();\n- if (t == null) {\n- throw new IllegalStateException(\"Not in a transaction\");\n- }\n- return t;\n- }\n-\n- public ReadTransaction getReadTransaction() {\n- Transaction transaction = getTransaction();\n- if (!(transaction instanceof ReadTransaction)) {\n- throw new IllegalStateException(\"Not in a read transaction\");\n- }\n- return (ReadTransaction) transaction;\n- }\n-\n- public WriteTransaction getWriteTransaction() {\n- Transaction transaction = getTransaction();\n- if (!(transaction instanceof WriteTransaction)) {\n- throw new IllegalStateException(\"Not in a write transaction\");\n- }\n- return (WriteTransaction) transaction;\n- }\n-\n- @Override\n- public void addListener(IBranchListener l) {\n- listeners = COWArrays.addIfAbsent(listeners, l);\n- }\n-\n- @Override\n- public void removeListener(IBranchListener l) {\n- listeners = COWArrays.remove(listeners, l);\n- }\n-\n- protected void notifyTreeChange(ITree oldTree, ITree newTree) {\n- if (oldTree == newTree) {\n- return;\n- }\n- for (IBranchListener l : listeners) {\n- try {\n- l.treeChanged(oldTree, newTree);\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"Exception in branch listener\", ex);\n- }\n- }\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/api/PBranch.kt", "diff": "+package org.modelix.model.api\n+\n+import org.apache.commons.lang3.mutable.MutableObject\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import org.modelix.model.api.DefaultIdGenerator.Companion.instance\n+import org.modelix.model.util.ContextValue\n+import org.modelix.model.util.pmap.COWArrays\n+import java.util.function.Supplier\n+\n+class PBranch @JvmOverloads constructor(@field:Volatile private var tree: ITree?, private val idGenerator: IIdGenerator? = instance) : IBranch {\n+ private val writeLock = Any()\n+ private val contextTransactions = ContextValue<Transaction?>()\n+ private var listeners = arrayOfNulls<IBranchListener>(0)\n+ fun runWithTransaction(transaction: ITransaction?, runnable: Runnable?) {\n+ contextTransactions.runWith(transaction as Transaction?, runnable!!)\n+ }\n+\n+ override fun runRead(runnable: Runnable?) {\n+ val prevTransaction = contextTransactions.getValue()\n+ if (prevTransaction is IReadTransaction) {\n+ runnable!!.run()\n+ } else {\n+ val currentTree = if (prevTransaction == null) tree else prevTransaction.tree\n+ val t = ReadTransaction(currentTree, this)\n+ contextTransactions.runWith(t, runnable!!)\n+ }\n+ }\n+\n+ override fun runWrite(runnable: Runnable?) {\n+ synchronized(writeLock) {\n+ val prevTransaction = contextTransactions.getValue()\n+ check(prevTransaction !is ReadTransaction) { \"Cannot run write from read\" }\n+ val prevWrite = prevTransaction as WriteTransaction?\n+ val oldTree = if (prevWrite == null) tree else prevWrite.tree\n+ val newWrite = WriteTransaction(oldTree, this, idGenerator!!)\n+ try {\n+ contextTransactions.runWith(newWrite, runnable!!)\n+ newWrite.close()\n+ val newTree = newWrite.tree\n+ if (prevWrite == null) {\n+ tree = newTree\n+ notifyTreeChange(oldTree, newTree)\n+ } else {\n+ prevWrite.tree = newTree\n+ }\n+ } finally {\n+ newWrite.close()\n+ }\n+ }\n+ }\n+\n+ override fun <T> computeRead(computable: Supplier<T>?): T {\n+ val result = MutableObject<T>()\n+ runRead(Runnable { result.setValue(computable!!.get()) })\n+ return result.value\n+ }\n+\n+ override fun <T> computeWrite(computable: Supplier<T>?): T {\n+ val result = MutableObject<T>()\n+ runWrite(Runnable { result.setValue(computable!!.get()) })\n+ return result.value\n+ }\n+\n+ override fun canRead(): Boolean {\n+ return contextTransactions.getValue() != null\n+ }\n+\n+ override fun canWrite(): Boolean {\n+ return contextTransactions.getValue() is IWriteTransaction\n+ }\n+\n+ override val transaction: Transaction\n+ get() = contextTransactions.getValue() ?: throw IllegalStateException(\"Not in a transaction\")\n+\n+ override val readTransaction: ReadTransaction\n+ get() {\n+ val transaction = transaction\n+ check(transaction is ReadTransaction) { \"Not in a read transaction\" }\n+ return transaction\n+ }\n+\n+ override val writeTransaction: WriteTransaction\n+ get() {\n+ val transaction = transaction\n+ check(transaction is WriteTransaction) { \"Not in a write transaction\" }\n+ return transaction\n+ }\n+\n+ override fun addListener(l: IBranchListener?) {\n+ listeners = COWArrays.addIfAbsent(listeners, l)\n+ }\n+\n+ override fun removeListener(l: IBranchListener?) {\n+ listeners = COWArrays.remove(listeners, l)\n+ }\n+\n+ protected fun notifyTreeChange(oldTree: ITree?, newTree: ITree?) {\n+ if (oldTree === newTree) {\n+ return\n+ }\n+ for (l in listeners) {\n+ try {\n+ l!!.treeChanged(oldTree, newTree)\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"Exception in branch listener\", ex)\n+ }\n+ }\n+ }\n+ }\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(PBranch::class.java)\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert PBranch
426,504
01.08.2020 12:58:57
-7,200
17cb3ac7540a739c73bd9604f90367708843398b
complete conversions of api package
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/api/CompositeNodeResolveContext.java", "new_path": null, "diff": "-package org.modelix.model.api;\n-\n-import org.modelix.model.util.StreamUtils;\n-\n-import java.util.Arrays;\n-import java.util.List;\n-import java.util.Objects;\n-import java.util.stream.Collectors;\n-\n-public class CompositeNodeResolveContext implements INodeResolveContext {\n- public static void withAdditionalContext(INodeResolveContext context, Runnable runnable) {\n- INodeResolveContext activeContext = INodeResolveContext.CONTEXT_VALUE.getValue();\n- if (activeContext == null) {\n- INodeResolveContext.CONTEXT_VALUE.runWith(context, runnable);\n- } else {\n- INodeResolveContext.CONTEXT_VALUE.runWith(new CompositeNodeResolveContext(context, activeContext), runnable);\n- }\n- }\n-\n- private List<INodeResolveContext> contexts;\n-\n- public CompositeNodeResolveContext(Iterable<INodeResolveContext> contexts) {\n- this.contexts = StreamUtils.INSTANCE.toStream(contexts).collect(Collectors.toList());\n- }\n-\n- public CompositeNodeResolveContext(INodeResolveContext... contexts) {\n- this(Arrays.asList(contexts));\n- }\n-\n- @Override\n- public INode resolve(final INodeReference ref) {\n- return contexts.stream().map(it -> it.resolve(ref)).filter(Objects::nonNull).findFirst().orElse(null);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/api/CompositeNodeResolveContext.kt", "diff": "+package org.modelix.model.api\n+\n+import org.modelix.model.util.StreamUtils.toStream\n+import java.util.*\n+import java.util.function.Predicate\n+import java.util.stream.Collectors\n+\n+class CompositeNodeResolveContext(contexts: Iterable<INodeResolveContext?>) : INodeResolveContext {\n+ private val contexts: List<INodeResolveContext?>\n+\n+ constructor(vararg contexts: INodeResolveContext?) : this(contexts.toList()) {}\n+\n+ override fun resolve(ref: INodeReference?): INode? {\n+ return contexts.stream().map { it?.resolve(ref) }.filter { obj: INode? -> Objects.nonNull(obj) }.findFirst().orElse(null)\n+ }\n+\n+ companion object {\n+ fun withAdditionalContext(context: INodeResolveContext?, runnable: Runnable?) {\n+ val activeContext = INodeResolveContext.CONTEXT_VALUE.getValue()\n+ if (activeContext == null) {\n+ INodeResolveContext.CONTEXT_VALUE.runWith(context!!, runnable!!)\n+ } else {\n+ INodeResolveContext.CONTEXT_VALUE.runWith(CompositeNodeResolveContext(context, activeContext), runnable!!)\n+ }\n+ }\n+ }\n+\n+ init {\n+ this.contexts = contexts.toList()\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/api/NodeUtil.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/api/NodeUtil.kt", "diff": "" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/api/PBranch.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/api/PBranch.kt", "diff": "" } ]
Kotlin
Apache License 2.0
modelix/modelix
complete conversions of api package
426,504
01.08.2020 13:00:40
-7,200
889c0a251c90c2f7d48e40a93b6bb298e947c5f9
convert ActiveBranch
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/ActiveBranch.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.api.IBranch;\n-import org.modelix.model.api.IBranchListener;\n-import org.modelix.model.api.ITree;\n-import org.apache.log4j.Level;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.modelix.model.lazy.CLVersion;\n-import org.modelix.model.lazy.TreeId;\n-\n-import java.util.ArrayList;\n-import java.util.List;\n-import java.util.Objects;\n-import java.util.function.Supplier;\n-\n-public class ActiveBranch implements IIndirectBranch {\n- private static final Logger LOG = LogManager.getLogger(ActiveBranch.class);\n- public static final String DEFAULT_BRANCH_NAME = \"master\";\n-\n- private IModelClient client;\n- private TreeId tree;\n- private String branchName;\n- private Supplier<String> user;\n- private ReplicatedTree replicatedTree;\n- private ITree lastKnownTree = null;\n- private IBranchListener forwardingListener = (oldTree, newTree) -> notifyListeners(newTree);\n- private List<IBranchListener> listeners = new ArrayList<>();\n-\n- public ActiveBranch(IModelClient client, TreeId tree, String branchName, Supplier<String> user) {\n- if ((branchName == null || branchName.length() == 0)) {\n- branchName = DEFAULT_BRANCH_NAME;\n- }\n- this.client = client;\n- this.tree = tree;\n- this.branchName = branchName;\n- this.user = user;\n- replicatedTree = new ReplicatedTree(client, tree, branchName, user);\n- lastKnownTree = replicatedTree.getBranch().computeRead(() -> replicatedTree.getBranch().getTransaction().getTree());\n- replicatedTree.getBranch().addListener(forwardingListener);\n- }\n-\n- public synchronized IBranch getBranch() {\n- return replicatedTree.getBranch();\n- }\n-\n- public CLVersion getVersion() {\n- return replicatedTree.getVersion();\n- }\n-\n- public String getBranchName() {\n- return this.branchName;\n- }\n-\n- public void dispose() {\n- replicatedTree.getBranch().removeListener(forwardingListener);\n- replicatedTree.dispose();\n- replicatedTree = null;\n- }\n-\n- public void addListener(IBranchListener l) {\n- List<IBranchListener> newListeners = new ArrayList<>(listeners);\n- newListeners.add(l);\n- listeners = newListeners;\n- }\n-\n- public void removeListener(IBranchListener l) {\n- List<IBranchListener> newListeners = new ArrayList<>(listeners);\n- newListeners.remove(l);\n- listeners = newListeners;\n- }\n-\n- public synchronized void switchBranch(String name) {\n- if (Objects.equals(branchName, name)) {\n- return;\n- }\n- branchName = name;\n- replicatedTree.getBranch().removeListener(forwardingListener);\n- replicatedTree.dispose();\n- replicatedTree = new ReplicatedTree(client, tree, branchName, user);\n- replicatedTree.getBranch().addListener(forwardingListener);\n- final IBranch b = replicatedTree.getBranch();\n- ITree newTree = b.computeRead(() -> b.getTransaction().getTree());\n- notifyListeners(newTree);\n- }\n-\n- protected void notifyListeners(ITree newTree) {\n- ITree oldTree = lastKnownTree;\n- lastKnownTree = newTree;\n- for (IBranchListener l : listeners) {\n- try {\n- l.treeChanged(oldTree, newTree);\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- }\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/ActiveBranch.kt", "diff": "+package org.modelix.model.client\n+\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import org.modelix.model.api.IBranch\n+import org.modelix.model.api.IBranchListener\n+import org.modelix.model.api.ITree\n+import org.modelix.model.client.ActiveBranch\n+import org.modelix.model.lazy.CLVersion\n+import org.modelix.model.lazy.TreeId\n+import java.util.*\n+import java.util.function.Supplier\n+\n+class ActiveBranch(client: IModelClient, tree: TreeId, branchName: String?, user: Supplier<String>) : IIndirectBranch {\n+ private val client: IModelClient\n+ private val tree: TreeId\n+ var branchName: String?\n+ private set\n+ private val user: Supplier<String>\n+ private var replicatedTree: ReplicatedTree?\n+ private var lastKnownTree: ITree? = null\n+ private val forwardingListener: IBranchListener = object : IBranchListener {\n+ override fun treeChanged(oldTree: ITree?, newTree: ITree?) {\n+ notifyListeners(newTree)\n+ }\n+ }\n+ private var listeners: List<IBranchListener?> = ArrayList()\n+\n+ @get:Synchronized\n+ override val branch: IBranch\n+ get() = replicatedTree!!.branch\n+\n+ val version: CLVersion\n+ get() = replicatedTree!!.version\n+\n+ fun dispose() {\n+ replicatedTree!!.branch.removeListener(forwardingListener)\n+ replicatedTree!!.dispose()\n+ replicatedTree = null\n+ }\n+\n+ override fun addListener(l: IBranchListener?) {\n+ val newListeners: MutableList<IBranchListener?> = ArrayList(listeners)\n+ newListeners.add(l)\n+ listeners = newListeners\n+ }\n+\n+ override fun removeListener(l: IBranchListener?) {\n+ val newListeners: MutableList<IBranchListener?> = ArrayList(listeners)\n+ newListeners.remove(l)\n+ listeners = newListeners\n+ }\n+\n+ @Synchronized\n+ fun switchBranch(name: String?) {\n+ if (branchName == name) {\n+ return\n+ }\n+ branchName = name\n+ replicatedTree!!.branch.removeListener(forwardingListener)\n+ replicatedTree!!.dispose()\n+ replicatedTree = ReplicatedTree(client, tree, branchName!!, user)\n+ replicatedTree!!.branch.addListener(forwardingListener)\n+ val b = replicatedTree!!.branch\n+ val newTree = b.computeRead(Supplier { b.transaction!!.tree })\n+ notifyListeners(newTree)\n+ }\n+\n+ protected fun notifyListeners(newTree: ITree?) {\n+ val oldTree = lastKnownTree\n+ lastKnownTree = newTree\n+ for (l in listeners) {\n+ try {\n+ l!!.treeChanged(oldTree, newTree)\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ }\n+ }\n+ }\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(ActiveBranch::class.java)\n+ const val DEFAULT_BRANCH_NAME = \"master\"\n+ }\n+\n+ init {\n+ var branchName = branchName\n+ if (branchName == null || branchName!!.length == 0) {\n+ branchName = DEFAULT_BRANCH_NAME\n+ }\n+ this.client = client\n+ this.tree = tree\n+ this.branchName = branchName\n+ this.user = user\n+ replicatedTree = ReplicatedTree(client, tree, branchName!!, user)\n+ lastKnownTree = replicatedTree!!.branch.computeRead(Supplier { replicatedTree!!.branch.transaction!!.tree })\n+ replicatedTree!!.branch.addListener(forwardingListener)\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/client/IIndirectBranch.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/IIndirectBranch.kt", "diff": "" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/client/IModelClient.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/IModelClient.kt", "diff": "" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert ActiveBranch
426,504
01.08.2020 13:01:23
-7,200
4f127f4247940a3deb4b16c839088428121c62e6
convert AsyncStore
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/AsyncStore.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.apache.log4j.Level;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.modelix.model.IKeyListener;\n-import org.modelix.model.IKeyValueStore;\n-import org.modelix.model.util.StreamUtils;\n-\n-import java.util.Iterator;\n-import java.util.LinkedHashMap;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.Objects;\n-import java.util.concurrent.atomic.AtomicBoolean;\n-import java.util.stream.Collectors;\n-\n-public class AsyncStore implements IKeyValueStore {\n- private static final Logger LOG = LogManager.getLogger(AsyncStore.class);\n- private IKeyValueStore store;\n-\n- private final AtomicBoolean consumerActive = new AtomicBoolean();\n- private final Map<String, String> pendingWrites = new LinkedHashMap<>(16, (float) 0.75, false);\n-\n- public AsyncStore(IKeyValueStore store) {\n- this.store = store;\n- }\n-\n- @Override\n- public String get(String key) {\n- synchronized (pendingWrites) {\n- if (pendingWrites.containsKey(key)) {\n- return pendingWrites.get(key);\n- }\n- }\n- return store.get(key);\n- }\n-\n- @Override\n- public void listen(final String key, final IKeyListener listener) {\n- store.listen(key, listener);\n- }\n-\n- @Override\n- public void removeListener(final String key, final IKeyListener listener) {\n- store.removeListener(key, listener);\n- }\n-\n- @Override\n- public void put(final String key, final String value) {\n- synchronized (pendingWrites) {\n- pendingWrites.put(key, value);\n- }\n- processQueue();\n- }\n-\n- @Override\n- public Map<String, String> getAll(Iterable<String> keys_) {\n- List<String> keys = StreamUtils.INSTANCE.toStream(keys_).collect(Collectors.toList());\n- Map<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\n- synchronized (pendingWrites) {\n- Iterator<String> itr = keys.iterator();\n- while (itr.hasNext()) {\n- String key = itr.next();\n- // always put even if null to have the same order in the linked hash map as in the input\n- result.put(key, pendingWrites.get(key));\n- if (pendingWrites.containsKey(key)) {\n- itr.remove();\n- }\n- }\n- }\n- if (!keys.isEmpty()) {\n- result.putAll(store.getAll(keys));\n- }\n- return result;\n- }\n-\n- @Override\n- public void putAll(Map<String, String> entries) {\n- synchronized (pendingWrites) {\n- pendingWrites.putAll(entries);\n- }\n- processQueue();\n- }\n-\n- @Override\n- public void prefetch(String key) {\n- store.prefetch(key);\n- }\n-\n- protected void processQueue() {\n- if (consumerActive.compareAndSet(false, true)) {\n- SharedExecutors.FIXED.execute(new Runnable() {\n- public void run() {\n- try {\n- while (!pendingWrites.isEmpty()) {\n- try {\n- Map<String, String> entries = new LinkedHashMap<String, String>(16, (float) 0.75, false);\n- synchronized (pendingWrites) {\n- entries.putAll(pendingWrites);\n- }\n- store.putAll(entries);\n- synchronized (pendingWrites) {\n- for (var entry : entries.entrySet()) {\n- if (Objects.equals(pendingWrites.get(entry.getKey()), entry.getValue())) {\n- pendingWrites.remove(entry.getKey());\n- }\n- }\n- }\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- try {\n- Thread.sleep(1000);\n- } catch (InterruptedException ex2) {\n- return;\n- }\n- }\n- }\n- } finally {\n- consumerActive.set(false);\n- }\n- }\n- });\n- }\n- }\n-\n- public void dispose() {\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/AsyncStore.kt", "diff": "+package org.modelix.model.client\n+\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import org.modelix.model.IKeyListener\n+import org.modelix.model.IKeyValueStore\n+import org.modelix.model.util.StreamUtils.toStream\n+import java.lang.Runnable\n+import java.util.*\n+import java.util.concurrent.atomic.AtomicBoolean\n+import java.util.stream.Collectors\n+\n+class AsyncStore(private val store: IKeyValueStore) : IKeyValueStore {\n+ private val consumerActive = AtomicBoolean()\n+ private val pendingWrites: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ override fun get(key: String?): String? {\n+ synchronized(pendingWrites) {\n+ if (pendingWrites.containsKey(key)) {\n+ return pendingWrites.get(key)\n+ }\n+ }\n+ return store[key]\n+ }\n+\n+ override fun listen(key: String?, listener: IKeyListener?) {\n+ store.listen(key, listener)\n+ }\n+\n+ override fun removeListener(key: String?, listener: IKeyListener?) {\n+ store.removeListener(key, listener)\n+ }\n+\n+ override fun put(key: String?, value: String?) {\n+ synchronized(pendingWrites) { pendingWrites.put(key, value) }\n+ processQueue()\n+ }\n+\n+ override fun getAll(keys_: Iterable<String?>?): Map<String?, String?>? {\n+ val keys = toStream((keys_)!!).collect(Collectors.toList())\n+ val result: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ synchronized(pendingWrites) {\n+ val itr: MutableIterator<String?> = keys.iterator()\n+ while (itr.hasNext()) {\n+ val key: String? = itr.next()\n+ // always put even if null to have the same order in the linked hash map as in the input\n+ result.put(key, pendingWrites.get(key))\n+ if (pendingWrites.containsKey(key)) {\n+ itr.remove()\n+ }\n+ }\n+ }\n+ if (!keys.isEmpty()) {\n+ result.putAll((store.getAll(keys))!!)\n+ }\n+ return result\n+ }\n+\n+ override fun putAll(entries: Map<String?, String?>?) {\n+ synchronized(pendingWrites) { pendingWrites.putAll((entries)!!) }\n+ processQueue()\n+ }\n+\n+ override fun prefetch(key: String?) {\n+ store.prefetch(key)\n+ }\n+\n+ protected fun processQueue() {\n+ if (consumerActive.compareAndSet(false, true)) {\n+ SharedExecutors.FIXED.execute(Runnable {\n+ try {\n+ while (!pendingWrites.isEmpty()) {\n+ try {\n+ val entries: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ synchronized(pendingWrites) { entries.putAll(pendingWrites) }\n+ store.putAll(entries)\n+ synchronized(pendingWrites) {\n+ for (entry: Map.Entry<String?, String?> in entries.entries) {\n+ if (Objects.equals(pendingWrites.get(entry.key), entry.value)) {\n+ pendingWrites.remove(entry.key)\n+ }\n+ }\n+ }\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ try {\n+ Thread.sleep(1000)\n+ } catch (ex2: InterruptedException) {\n+ return@Runnable\n+ }\n+ }\n+ }\n+ } finally {\n+ consumerActive.set(false)\n+ }\n+ })\n+ }\n+ }\n+\n+ fun dispose() {}\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(AsyncStore::class.java)\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert AsyncStore
426,504
01.08.2020 13:02:34
-7,200
c3a5412796d1c0d72ad753618d60b3cf51d3ebde
convert GarbageFilteringStore
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/GarbageFilteringStore.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.IKeyListener;\n-import org.modelix.model.IKeyValueStore;\n-import org.modelix.model.util.StreamUtils;\n-import org.modelix.model.persistent.HashUtil;\n-\n-import java.util.Collections;\n-import java.util.HashMap;\n-import java.util.Iterator;\n-import java.util.LinkedHashMap;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.stream.Collectors;\n-\n-public class GarbageFilteringStore implements IKeyValueStore {\n-\n- private IKeyValueStore store;\n- private Map<String, String> pendingEntries = new HashMap<>();\n-\n- public GarbageFilteringStore(IKeyValueStore store) {\n- this.store = store;\n- }\n-\n- @Override\n- public String get(String key) {\n- return (pendingEntries.containsKey(key) ? pendingEntries.get(key) : store.get(key));\n- }\n-\n- @Override\n- public void put(String key, String value) {\n- putAll(Collections.singletonMap(key, value));\n- }\n-\n- @Override\n- public Map<String, String> getAll(Iterable<String> keys_) {\n- List<String> keys = StreamUtils.INSTANCE.toStream(keys_).collect(Collectors.toList());\n- Map<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\n- synchronized (pendingEntries) {\n- Iterator<String> itr = keys.iterator();\n- while (itr.hasNext()) {\n- String key = itr.next();\n- // always put even if null to have the same order in the linked hash map as in the input\n- result.put(key, pendingEntries.get(key));\n- if (pendingEntries.containsKey(key)) {\n- itr.remove();\n- }\n- }\n- }\n- if (!keys.isEmpty()) {\n- result.putAll(store.getAll(keys));\n- }\n- return result;\n- }\n-\n- @Override\n- public void putAll(Map<String, String> entries) {\n- Map<String, String> entriesToWrite = new LinkedHashMap<String, String>(16, (float) 0.75, false);\n- for (var entry : entries.entrySet()) {\n- if (HashUtil.isSha256(entry.getKey())) {\n- pendingEntries.put(entry.getKey(), entry.getValue());\n- } else {\n- collectDependencies(entry.getKey(), entry.getValue(), entriesToWrite);\n- }\n- }\n- if (!entriesToWrite.isEmpty()) {\n- var entry = entriesToWrite.entrySet().stream().findFirst();\n- if (entry.isPresent()) {\n- store.put(entry.get().getKey(), entry.get().getValue());\n- } else {\n- store.putAll(entriesToWrite);\n- }\n- }\n- }\n-\n- protected void collectDependencies(String key, String value, Map<String, String> acc) {\n- for (String depKey : HashUtil.extractSha256(value)) {\n- if (pendingEntries.containsKey(depKey)) {\n- String depValue = pendingEntries.remove(depKey);\n- collectDependencies(depKey, depValue, acc);\n- }\n- }\n- acc.put(key, value);\n- }\n-\n- @Override\n- public void prefetch(String key) {\n- store.prefetch(key);\n- }\n-\n- @Override\n- public void listen(final String key, final IKeyListener listener) {\n- store.listen(key, listener);\n- }\n-\n- @Override\n- public void removeListener(final String key, final IKeyListener listener) {\n- store.removeListener(key, listener);\n- }\n-}\n" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/client/ActiveBranch.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/ActiveBranch.kt", "diff": "" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/client/AsyncStore.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/AsyncStore.kt", "diff": "" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/client/GarbageFilteringStore.kt", "diff": "+package org.modelix.model.client\n+\n+import org.modelix.model.IKeyListener\n+import org.modelix.model.IKeyValueStore\n+import org.modelix.model.persistent.HashUtil\n+import org.modelix.model.util.StreamUtils.toStream\n+import java.util.*\n+import java.util.stream.Collectors\n+\n+class GarbageFilteringStore(private val store: IKeyValueStore) : IKeyValueStore {\n+ private val pendingEntries: MutableMap<String?, String?> = HashMap()\n+ override fun get(key: String?): String? {\n+ return if (pendingEntries.containsKey(key)) pendingEntries[key] else store[key]\n+ }\n+\n+ override fun put(key: String?, value: String?) {\n+ putAll(Collections.singletonMap(key, value))\n+ }\n+\n+ override fun getAll(keys_: Iterable<String?>?): Map<String?, String?>? {\n+ val keys = toStream(keys_!!).collect(Collectors.toList())\n+ val result: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ synchronized(pendingEntries) {\n+ val itr = keys.iterator()\n+ while (itr.hasNext()) {\n+ val key = itr.next()\n+ // always put even if null to have the same order in the linked hash map as in the input\n+ result[key] = pendingEntries[key]\n+ if (pendingEntries.containsKey(key)) {\n+ itr.remove()\n+ }\n+ }\n+ }\n+ if (!keys.isEmpty()) {\n+ result.putAll(store.getAll(keys)!!)\n+ }\n+ return result\n+ }\n+\n+ override fun putAll(entries: Map<String?, String?>?) {\n+ val entriesToWrite: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ for ((key, value) in entries!!) {\n+ if (HashUtil.isSha256(key)) {\n+ pendingEntries[key] = value\n+ } else {\n+ collectDependencies(key, value, entriesToWrite)\n+ }\n+ }\n+ if (!entriesToWrite.isEmpty()) {\n+ val entry: Optional<MutableMap.MutableEntry<String?, String?>> = entriesToWrite.entries.stream().findFirst()\n+ if (entry.isPresent) {\n+ store.put(entry.get().key, entry.get().value)\n+ } else {\n+ store.putAll(entriesToWrite)\n+ }\n+ }\n+ }\n+\n+ protected fun collectDependencies(key: String?, value: String?, acc: MutableMap<String?, String?>) {\n+ for (depKey in HashUtil.extractSha256(value)) {\n+ if (pendingEntries.containsKey(depKey)) {\n+ val depValue = pendingEntries.remove(depKey)\n+ collectDependencies(depKey, depValue, acc)\n+ }\n+ }\n+ acc[key] = value\n+ }\n+\n+ override fun prefetch(key: String?) {\n+ store.prefetch(key)\n+ }\n+\n+ override fun listen(key: String?, listener: IKeyListener?) {\n+ store.listen(key, listener)\n+ }\n+\n+ override fun removeListener(key: String?, listener: IKeyListener?) {\n+ store.removeListener(key, listener)\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert GarbageFilteringStore
426,504
01.08.2020 13:12:25
-7,200
ead9bb248ddc3bd4323678f8176b6b2a207a848d
translating IdGenerator
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/IdGenerator.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.api.IIdGenerator;\n-import java.util.concurrent.atomic.AtomicLong;\n-\n-public class IdGenerator implements IIdGenerator {\n- protected final AtomicLong idSequence;\n-\n- private long clientId;\n-\n- public IdGenerator(int clientId) {\n- this.clientId = clientId;\n- idSequence = new AtomicLong(this.clientId << 32);\n- }\n-\n- @Override\n- public long generate() {\n- long id = idSequence.incrementAndGet();\n- if (id >>> 32 != clientId) {\n- throw new RuntimeException(\"End of ID range\");\n- }\n- return id;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/IdGenerator.kt", "diff": "+package org.modelix.model.client\n+\n+import org.modelix.model.api.IIdGenerator\n+import java.util.concurrent.atomic.AtomicLong\n+\n+class IdGenerator(clientId: Int) : IIdGenerator {\n+ protected val idSequence: AtomicLong\n+ private val clientId: Long\n+ override fun generate(): Long {\n+ val id = idSequence.incrementAndGet()\n+ if (id ushr 32 != clientId) {\n+ throw RuntimeException(\"End of ID range\")\n+ }\n+ return id\n+ }\n+\n+ init {\n+ this.clientId = clientId.toLong()\n+ idSequence = AtomicLong(this.clientId shl 32)\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/client/ActiveBranch.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/ActiveBranch.kt", "diff": "@@ -31,7 +31,7 @@ class ActiveBranch(client: IModelClient, tree: TreeId, branchName: String?, user\nget() = replicatedTree!!.branch\nval version: CLVersion\n- get() = replicatedTree!!.version\n+ get() = replicatedTree!!.version!!\nfun dispose() {\nreplicatedTree!!.branch.removeListener(forwardingListener)\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translating IdGenerator
426,504
01.08.2020 13:14:50
-7,200
3d2ea076d1e432d703cc2e14f418421e94e107cb
migrate SharedExecutors
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/SharedExecutors.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.apache.log4j.Logger;\n-import org.apache.log4j.LogManager;\n-import java.util.concurrent.ExecutorService;\n-import java.util.concurrent.Executors;\n-import java.util.concurrent.ScheduledExecutorService;\n-import java.util.concurrent.ScheduledFuture;\n-import org.apache.log4j.Level;\n-import java.util.concurrent.TimeUnit;\n-\n-public class SharedExecutors {\n- private static final Logger LOG = LogManager.getLogger(SharedExecutors.class);\n- public static final ExecutorService FIXED = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);\n- public static final ScheduledExecutorService SCHEDULED = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors() + 1);\n-\n- public static void shutdownAll() {\n- SCHEDULED.shutdown();\n- FIXED.shutdown();\n- }\n-\n- public static ScheduledFuture<?> fixDelay(int milliSeconds, final Runnable r) {\n- return SCHEDULED.scheduleWithFixedDelay(() -> {\n- try {\n- r.run();\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- }\n- }, milliSeconds, milliSeconds, TimeUnit.MILLISECONDS);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/SharedExecutors.kt", "diff": "+package org.modelix.model.client\n+\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import java.util.concurrent.Executors\n+import java.util.concurrent.ScheduledFuture\n+import java.util.concurrent.TimeUnit\n+\n+object SharedExecutors {\n+ private val LOG = LogManager.getLogger(SharedExecutors::class.java)\n+ @JvmField\n+ val FIXED = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1)\n+ val SCHEDULED = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors() + 1)\n+ fun shutdownAll() {\n+ SCHEDULED.shutdown()\n+ FIXED.shutdown()\n+ }\n+\n+ @JvmStatic\n+ fun fixDelay(milliSeconds: Int, r: Runnable): ScheduledFuture<*> {\n+ return SCHEDULED.scheduleWithFixedDelay({\n+ try {\n+ r.run()\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ }\n+ }, milliSeconds.toLong(), milliSeconds.toLong(), TimeUnit.MILLISECONDS)\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate SharedExecutors
426,504
01.08.2020 13:15:27
-7,200
c5a3c8a1ec56ccf5a2910b330a211a1a6cd6d886
migrate SimpleIndirectBranch
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/SimpleIndirectBranch.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.api.IBranch;\n-import org.modelix.model.api.IBranchListener;\n-\n-public class SimpleIndirectBranch implements IIndirectBranch {\n- private IBranch branch;\n-\n- public SimpleIndirectBranch(IBranch branch) {\n- this.branch = branch;\n- }\n- @Override\n- public void addListener(IBranchListener l) {\n- branch.addListener(l);\n- }\n- @Override\n- public IBranch getBranch() {\n- return branch;\n- }\n- @Override\n- public void removeListener(IBranchListener l) {\n- branch.removeListener(l);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/SimpleIndirectBranch.kt", "diff": "+package org.modelix.model.client\n+\n+import org.modelix.model.api.IBranch\n+import org.modelix.model.api.IBranchListener\n+\n+class SimpleIndirectBranch(override val branch: IBranch) : IIndirectBranch {\n+ override fun addListener(l: IBranchListener?) {\n+ branch.addListener(l)\n+ }\n+\n+ override fun removeListener(l: IBranchListener?) {\n+ branch.removeListener(l)\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate SimpleIndirectBranch
426,504
01.08.2020 13:20:53
-7,200
b2040cf87f7c2838397816c29fcea065d0f27102
migrate RestWebModelClient
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/RestWebModelClient.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.IKeyListener;\n-import org.modelix.model.IKeyValueStore;\n-import org.modelix.model.api.IIdGenerator;\n-import org.apache.commons.io.FileUtils;\n-import org.apache.log4j.Level;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.json.JSONArray;\n-import org.json.JSONObject;\n-import org.modelix.model.util.StreamUtils;\n-import org.modelix.model.KeyValueStoreCache;\n-import org.modelix.model.lazy.IDeserializingKeyValueStore;\n-import org.modelix.model.lazy.ObjectStoreCache;\n-import org.modelix.model.persistent.HashUtil;\n-\n-import javax.ws.rs.client.Client;\n-import javax.ws.rs.client.ClientBuilder;\n-import javax.ws.rs.client.ClientRequestContext;\n-import javax.ws.rs.client.ClientRequestFilter;\n-import javax.ws.rs.client.Entity;\n-import javax.ws.rs.client.WebTarget;\n-import javax.ws.rs.core.HttpHeaders;\n-import javax.ws.rs.core.MediaType;\n-import javax.ws.rs.core.Response;\n-import javax.ws.rs.sse.InboundSseEvent;\n-import javax.ws.rs.sse.SseEventSource;\n-import java.io.File;\n-import java.io.IOException;\n-import java.net.URLEncoder;\n-import java.nio.charset.StandardCharsets;\n-import java.util.ArrayList;\n-import java.util.HashMap;\n-import java.util.LinkedHashMap;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.Objects;\n-import java.util.concurrent.ScheduledFuture;\n-import java.util.concurrent.TimeUnit;\n-import java.util.function.Consumer;\n-import java.util.stream.Stream;\n-\n-public class RestWebModelClient implements IModelClient {\n- private static final Logger LOG = LogManager.getLogger(RestWebModelClient.class);\n- public static final String MODEL_URI_VAR_NAME = \"MODEL_URI\";\n- private static String defaultToken;\n-\n- static {\n- try {\n- File sharedSecretFile = new File(\"/secrets/modelsecret/modelsecret.txt\");\n- if (sharedSecretFile.exists()) {\n- defaultToken = FileUtils.readFileToString(sharedSecretFile, StandardCharsets.UTF_8);\n- }\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"Failed to load default token\", ex);\n- }\n- }\n- }\n-\n- public static String getModelUrlFromEnv() {\n- String url = System.getProperty(MODEL_URI_VAR_NAME);\n- if ((url == null || url.length() == 0)) {\n- url = System.getenv(MODEL_URI_VAR_NAME);\n- }\n- return url;\n- }\n-\n- public static String getDefaultUrl() {\n- String urlFromEnv = getModelUrlFromEnv();\n- if ((urlFromEnv != null && urlFromEnv.length() > 0)) {\n- return urlFromEnv;\n- } else {\n- return \"http://modelix.q60.de:80/model/\";\n- }\n- }\n-\n- private int clientId = 0;\n- private Client client;\n- private final List<SseListener> listeners = new ArrayList<>();\n- private String baseUrl;\n- private IKeyValueStore asyncStore = new GarbageFilteringStore(new AsyncStore(this));\n- private ObjectStoreCache cache = new ObjectStoreCache(new KeyValueStoreCache(asyncStore));\n- private IdGenerator idGenerator;\n- private ScheduledFuture<?> watchDogTask;\n- private String authToken = defaultToken;\n-\n- public RestWebModelClient() {\n- this(null);\n- }\n-\n- public RestWebModelClient(String baseUrl) {\n- this.baseUrl = baseUrl;\n- if (isEmptyString(this.baseUrl)) {\n- this.baseUrl = getDefaultUrl();\n- }\n- if (!(this.baseUrl.endsWith(\"/\"))) {\n- this.baseUrl += \"/\";\n- }\n-\n- client = ClientBuilder.newBuilder().register(new ClientRequestFilter() {\n- @Override\n- public void filter(ClientRequestContext ctx) throws IOException {\n- ctx.getHeaders().add(HttpHeaders.AUTHORIZATION, \"Bearer \" + authToken);\n- }\n- }).build();\n- watchDogTask = SharedExecutors.fixDelay(1000, new Runnable() {\n- public void run() {\n- List<SseListener> ls;\n- synchronized (listeners) {\n- ls = new ArrayList<SseListener>(listeners);\n- }\n- for (SseListener l : ls) {\n- try {\n- l.ensureConnected();\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- }\n- }\n- }\n- });\n- }\n-\n- public String getBaseUrl() {\n- return baseUrl;\n- }\n-\n- public void dispose() {\n- watchDogTask.cancel(false);\n- synchronized (listeners) {\n- listeners.forEach(SseListener::dispose);\n- listeners.clear();\n- }\n- }\n-\n- @Override\n- public String get(String key) {\n- boolean isHash = HashUtil.isSha256(key);\n- if (isHash) {\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"GET \" + key);\n- }\n- }\n- long start = System.currentTimeMillis();\n- Response response = client.target(baseUrl + \"get/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)).request().buildGet().invoke();\n- if (response.getStatus() == Response.Status.OK.getStatusCode()) {\n- String value = response.readEntity(String.class);\n- long end = System.currentTimeMillis();\n- if (isHash) {\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"GET \" + key + \" took \" + (end - start) + \" ms: \" + value);\n- }\n- }\n- return value;\n- } else if (response.getStatus() == Response.Status.NOT_FOUND.getStatusCode()) {\n- return null;\n- } else {\n- throw new RuntimeException(\"Request for key '\" + key + \"' failed: \" + response.getStatusInfo());\n- }\n- }\n-\n- @Override\n- public Map<String, String> getAll(Iterable<String> keys) {\n- if (!keys.iterator().hasNext()) {\n- return new HashMap<>();\n- }\n-\n- JSONArray json = new JSONArray();\n- for (String key : keys) {\n- json.put(key);\n- }\n- String body = json.toString();\n-\n- long start = System.currentTimeMillis();\n- Response response = client.target(baseUrl + \"getAll\").request(MediaType.APPLICATION_JSON).put(Entity.text(body));\n- if (response.getStatus() == Response.Status.OK.getStatusCode()) {\n- String jsonStr = response.readEntity(String.class);\n- JSONArray responseJson = new JSONArray(jsonStr);\n- Map<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\n- for (Object entry_ : responseJson) {\n- JSONObject entry = (JSONObject) entry_;\n- result.put(entry.getString(\"key\"), entry.optString(\"value\"));\n- }\n- long end = System.currentTimeMillis();\n- return result;\n- } else {\n- throw new RuntimeException(String.format(\"Request for %d keys failed (%s, ...): %s\",\n- keys.spliterator().getExactSizeIfKnown(),\n- StreamUtils.INSTANCE.toStream(keys).findFirst().orElse(null),\n- response.getStatusInfo()));\n- }\n- }\n-\n- public void setAuthToken(String token) {\n- this.authToken = token;\n- }\n-\n- public String getEmail() {\n- Response response = client.target(baseUrl + \"getEmail\").request().buildGet().invoke();\n- if (response.getStatus() == Response.Status.OK.getStatusCode()) {\n- return response.readEntity(String.class);\n- } else {\n- throw new RuntimeException(\"Request for e-mail address failed: \" + response.getStatusInfo());\n- }\n- }\n-\n- @Override\n- public void listen(final String key, final IKeyListener keyListener) {\n- SseListener sseListener = new SseListener(key, keyListener);\n- synchronized (listeners) {\n- listeners.add(sseListener);\n- }\n- }\n-\n- @Override\n- public void removeListener(final String key, final IKeyListener listener) {\n- synchronized (listeners) {\n- listeners.removeIf(it -> Objects.equals(it.key, key) && it.keyListener == listener);\n- }\n- }\n-\n- @Override\n- public void put(String key, String value) {\n- if (!(key.matches(\"[a-zA-Z0-9-_]{43}\"))) {\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"PUT \" + key + \" = \" + value);\n- }\n- }\n- Response response = client.target(baseUrl + \"put/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)).request(MediaType.TEXT_PLAIN).put(Entity.text(value));\n- if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {\n- throw new RuntimeException(\"Failed to store entry (\" + response.getStatusInfo() + \") \" + key + \" = \" + value);\n- }\n- }\n-\n- @Override\n- public void putAll(final Map<String, String> entries) {\n- Consumer<JSONArray> sendBatch = new Consumer<JSONArray>() {\n- public void accept(JSONArray json) {\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"PUT batch of \" + json.length() + \" entries\");\n- }\n- Response response = client.target(baseUrl + \"putAll\").request(MediaType.APPLICATION_JSON).put(Entity.text(json.toString()));\n- if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {\n- throw new RuntimeException(String.format(\"Failed to store %d entries (%s) %s\",\n- entries.size(),\n- response.getStatusInfo(),\n- entries.entrySet().stream().map(e -> e.getKey() + \" = \" + e.getValue() + \", ...\").findFirst().orElse(\"\")));\n- }\n- }\n- };\n-\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"PUT \" + entries.size() + \" entries\");\n- }\n- JSONArray json = new JSONArray();\n- int approxSize = 0;\n- for (var entry : entries.entrySet()) {\n- JSONObject jsonEntry = new JSONObject();\n- jsonEntry.put(\"key\", entry.getKey());\n- jsonEntry.put(\"value\", entry.getValue());\n- approxSize += entry.getKey().length();\n- approxSize += entry.getValue().length();\n- json.put(jsonEntry);\n- if (!(entry.getKey().matches(\"[a-zA-Z0-9-_]{43}\"))) {\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"PUT \" + entry.getKey() + \" = \" + entry.getValue());\n- }\n- }\n-\n- if (json.length() >= 5000 || approxSize > 10000000) {\n- sendBatch.accept(json);\n- json = new JSONArray();\n- approxSize = 0;\n- }\n- }\n- if (json.length() > 0) {\n- sendBatch.accept(json);\n- }\n- }\n-\n- @Override\n- public void prefetch(String key) {\n- }\n-\n- public int getClientId() {\n- if (clientId == 0) {\n- Response response = client.target(baseUrl + \"counter/clientId\").request().post(Entity.text(\"\"));\n- String idStr = response.readEntity(String.class);\n- clientId = Integer.parseInt(idStr);\n- }\n- return clientId;\n- }\n-\n- @Override\n- public IDeserializingKeyValueStore getStoreCache() {\n- return cache;\n- }\n-\n- @Override\n- public IKeyValueStore getAsyncStore() {\n- return asyncStore;\n- }\n-\n- @Override\n- public synchronized IIdGenerator getIdGenerator() {\n- if (idGenerator == null) {\n- idGenerator = new IdGenerator(getClientId());\n- }\n- return idGenerator;\n- }\n-\n- public class SseListener {\n- private String key;\n- private IKeyListener keyListener;\n- private final Object notificationLock = new Object();\n- private String lastValue;\n- private Sse[] sse = new Sse[2];\n- private boolean disposed = false;\n-\n- public SseListener(final String key, IKeyListener listener) {\n- this.key = key;\n- this.keyListener = listener;\n- }\n- public void dispose() {\n- if (disposed) {\n- return;\n- }\n- disposed = true;\n- for (int i = 0; i < sse.length; i++) {\n- if (sse[i] != null) {\n- sse[i].sse.close();\n- sse[i] = null;\n- }\n- }\n- }\n- public synchronized void ensureConnected() {\n- if (disposed) {\n- return;\n- }\n- for (int i = 0; i < sse.length; i++) {\n- if (sse[i] == null) {\n- continue;\n- }\n- if (sse[i].birth > System.currentTimeMillis()) {\n- sse[i].birth = System.currentTimeMillis();\n- }\n- if (!(sse[i].sse.isOpen())) {\n- sse[i] = null;\n- }\n- }\n-\n- for (int i = 0; i < sse.length; i++) {\n- // To support rebalancing after scaling the cluster a connection shouldn't be open for too long.\n- if (sse[i] != null && sse[i].getAge() > 20000) {\n- sse[i].sse.close();\n- sse[i] = null;\n- }\n- }\n-\n- long youngest = Stream.of(sse).filter(Objects::nonNull).mapToLong(it -> it.birth).reduce(0L, Math::max);\n-\n- if (System.currentTimeMillis() - youngest < 5000) {\n- return;\n- }\n-\n- for (int i = 0; i < sse.length; i++) {\n- if (sse[i] != null) {\n- continue;\n- }\n- String url = baseUrl + \"subscribe/\" + URLEncoder.encode(key, StandardCharsets.UTF_8);\n- if (LOG.isTraceEnabled()) {\n- LOG.trace(\"Connecting to \" + url);\n- }\n- WebTarget target = client.target(url);\n- sse[i] = new Sse(SseEventSource.target(target).reconnectingEvery(1, TimeUnit.SECONDS).build());\n- sse[i].sse.register(new Consumer<InboundSseEvent>() {\n- @Override\n- public void accept(InboundSseEvent event) {\n- String value = event.readData();\n- synchronized (notificationLock) {\n- if (!(Objects.equals(value, lastValue))) {\n- lastValue = value;\n- keyListener.changed(key, value);\n- }\n- }\n- }\n- }, new Consumer<Throwable>() {\n- @Override\n- public void accept(Throwable ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- }\n- });\n- if (disposed) {\n- return;\n- }\n- sse[i].sse.open();\n- if (LOG.isTraceEnabled()) {\n- LOG.trace(\"Connected to \" + url);\n- }\n- break;\n- }\n- }\n- public class Sse {\n- private long birth = System.currentTimeMillis();\n- private SseEventSource sse;\n- public Sse(SseEventSource sse) {\n- this.sse = sse;\n- }\n- public long getAge() {\n- return System.currentTimeMillis() - birth;\n- }\n- }\n- }\n-\n- private static boolean isEmptyString(String str) {\n- return str == null || str.length() == 0;\n- }\n-}\n" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/client/IdGenerator.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/IdGenerator.kt", "diff": "" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/client/RestWebModelClient.kt", "diff": "+package org.modelix.model.client\n+\n+import org.apache.commons.io.FileUtils\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import org.json.JSONArray\n+import org.json.JSONObject\n+import org.modelix.model.IKeyListener\n+import org.modelix.model.IKeyValueStore\n+import org.modelix.model.KeyValueStoreCache\n+import org.modelix.model.client.SharedExecutors.fixDelay\n+import org.modelix.model.lazy.IDeserializingKeyValueStore\n+import org.modelix.model.lazy.ObjectStoreCache\n+import org.modelix.model.persistent.HashUtil\n+import org.modelix.model.util.StreamUtils.toStream\n+import java.io.File\n+import java.io.IOException\n+import java.net.URLEncoder\n+import java.nio.charset.StandardCharsets\n+import java.util.*\n+import java.util.concurrent.ScheduledFuture\n+import java.util.concurrent.TimeUnit\n+import java.util.function.Consumer\n+import java.util.function.Predicate\n+import java.util.function.ToLongFunction\n+import java.util.stream.Stream\n+import javax.ws.rs.client.*\n+import javax.ws.rs.core.HttpHeaders\n+import javax.ws.rs.core.MediaType\n+import javax.ws.rs.core.Response\n+import javax.ws.rs.sse.SseEventSource\n+\n+class RestWebModelClient @JvmOverloads constructor(var baseUrl: String? = null) : IModelClient {\n+ companion object {\n+ private val LOG = LogManager.getLogger(RestWebModelClient::class.java)\n+ const val MODEL_URI_VAR_NAME = \"MODEL_URI\"\n+ private var defaultToken: String? = null\n+ val modelUrlFromEnv: String?\n+ get() {\n+ var url = System.getProperty(MODEL_URI_VAR_NAME)\n+ if (url == null || url.length == 0) {\n+ url = System.getenv(MODEL_URI_VAR_NAME)\n+ }\n+ return url\n+ }\n+\n+ val defaultUrl: String\n+ get() {\n+ val urlFromEnv = modelUrlFromEnv\n+ return if ((urlFromEnv != null && urlFromEnv.length > 0)) {\n+ urlFromEnv\n+ } else {\n+ \"http://modelix.q60.de:80/model/\"\n+ }\n+ }\n+\n+ private fun isEmptyString(str: String?): Boolean {\n+ return str == null || str.length == 0\n+ }\n+\n+ init {\n+ try {\n+ val sharedSecretFile = File(\"/secrets/modelsecret/modelsecret.txt\")\n+ if (sharedSecretFile.exists()) {\n+ defaultToken = FileUtils.readFileToString(sharedSecretFile, StandardCharsets.UTF_8)\n+ }\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"Failed to load default token\", ex)\n+ }\n+ }\n+ }\n+ }\n+\n+ override var clientId = 0\n+ get() {\n+ if (field == 0) {\n+ val response = client.target(baseUrl + \"counter/clientId\").request().post(Entity.text(\"\"))\n+ val idStr = response.readEntity(String::class.java)\n+ field = idStr.toInt()\n+ }\n+ return field\n+ }\n+ private set\n+ private val client: Client\n+ private val listeners: MutableList<SseListener> = ArrayList()\n+ override val asyncStore: IKeyValueStore = GarbageFilteringStore(AsyncStore(this))\n+ private val cache = ObjectStoreCache(KeyValueStoreCache(asyncStore))\n+\n+ @get:Synchronized\n+ override var idGenerator: IdGenerator? = null\n+ get() {\n+ if (field == null) {\n+ field = IdGenerator(clientId)\n+ }\n+ return field\n+ }\n+ private set\n+ private val watchDogTask: ScheduledFuture<*>\n+ private var authToken = defaultToken\n+\n+ fun dispose() {\n+ watchDogTask.cancel(false)\n+ synchronized(listeners) {\n+ listeners.forEach(Consumer { obj: SseListener -> obj.dispose() })\n+ listeners.clear()\n+ }\n+ }\n+\n+ override fun get(key: String?): String? {\n+ val isHash = HashUtil.isSha256(key)\n+ if (isHash) {\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"GET $key\")\n+ }\n+ }\n+ val start = System.currentTimeMillis()\n+ val response = client.target(baseUrl + \"get/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)).request().buildGet().invoke()\n+ return if (response.status == Response.Status.OK.statusCode) {\n+ val value = response.readEntity(String::class.java)\n+ val end = System.currentTimeMillis()\n+ if (isHash) {\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"GET \" + key + \" took \" + (end - start) + \" ms: \" + value)\n+ }\n+ }\n+ value\n+ } else if (response.status == Response.Status.NOT_FOUND.statusCode) {\n+ null\n+ } else {\n+ throw RuntimeException(\"Request for key '\" + key + \"' failed: \" + response.statusInfo)\n+ }\n+ }\n+\n+ override fun getAll(keys: Iterable<String?>?): Map<String?, String?>? {\n+ if (!keys!!.iterator().hasNext()) {\n+ return HashMap()\n+ }\n+ val json = JSONArray()\n+ for (key in keys) {\n+ json.put(key)\n+ }\n+ val body = json.toString()\n+ val start = System.currentTimeMillis()\n+ val response = client.target(baseUrl + \"getAll\").request(MediaType.APPLICATION_JSON).put(Entity.text(body))\n+ return if (response.status == Response.Status.OK.statusCode) {\n+ val jsonStr = response.readEntity(String::class.java)\n+ val responseJson = JSONArray(jsonStr)\n+ val result: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ for (entry_: Any in responseJson) {\n+ val entry = entry_ as JSONObject\n+ result[entry.getString(\"key\")] = entry.optString(\"value\")\n+ }\n+ val end = System.currentTimeMillis()\n+ result\n+ } else {\n+ throw RuntimeException(String.format(\"Request for %d keys failed (%s, ...): %s\",\n+ keys.spliterator().exactSizeIfKnown,\n+ toStream(keys).findFirst().orElse(null),\n+ response.statusInfo))\n+ }\n+ }\n+\n+ fun setAuthToken(token: String?) {\n+ authToken = token\n+ }\n+\n+ val email: String\n+ get() {\n+ val response = client.target(baseUrl + \"getEmail\").request().buildGet().invoke()\n+ return if (response.status == Response.Status.OK.statusCode) {\n+ response.readEntity(String::class.java)\n+ } else {\n+ throw RuntimeException(\"Request for e-mail address failed: \" + response.statusInfo)\n+ }\n+ }\n+\n+ override fun listen(key: String?, keyListener: IKeyListener?) {\n+ val sseListener = SseListener(key, keyListener)\n+ synchronized(listeners) { listeners.add(sseListener) }\n+ }\n+\n+ override fun removeListener(key: String?, listener: IKeyListener?) {\n+ synchronized(listeners) { listeners.removeIf({ it: SseListener -> Objects.equals(it.key, key) && it.keyListener === listener }) }\n+ }\n+\n+ override fun put(key: String?, value: String?) {\n+ if (!key!!.matches(Regex(\"[a-zA-Z0-9-_]{43}\"))) {\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"PUT $key = $value\")\n+ }\n+ }\n+ val response = client.target(baseUrl + \"put/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)).request(MediaType.TEXT_PLAIN).put(Entity.text(value))\n+ if (response.statusInfo.family != Response.Status.Family.SUCCESSFUL) {\n+ throw RuntimeException(\"Failed to store entry (\" + response.statusInfo + \") \" + key + \" = \" + value)\n+ }\n+ }\n+\n+ override fun putAll(entries: Map<String?, String?>?) {\n+ val sendBatch = Consumer<JSONArray> { json ->\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"PUT batch of \" + json.length() + \" entries\")\n+ }\n+ val response = client.target(baseUrl + \"putAll\").request(MediaType.APPLICATION_JSON).put(Entity.text(json.toString()))\n+ if (response.statusInfo.family != Response.Status.Family.SUCCESSFUL) {\n+ throw RuntimeException(String.format(\"Failed to store %d entries (%s) %s\",\n+ entries!!.size,\n+ response.statusInfo,\n+ entries.entries.stream().map { e: Map.Entry<String?, String?> -> e.key.toString() + \" = \" + e.value + \", ...\" }.findFirst().orElse(\"\")))\n+ }\n+ }\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"PUT \" + entries!!.size + \" entries\")\n+ }\n+ var json = JSONArray()\n+ var approxSize = 0\n+ for ((key, value) in entries!!) {\n+ val jsonEntry = JSONObject()\n+ jsonEntry.put(\"key\", key)\n+ jsonEntry.put(\"value\", value)\n+ approxSize += key!!.length\n+ approxSize += value!!.length\n+ json.put(jsonEntry)\n+ if (!key.matches(Regex(\"[a-zA-Z0-9-_]{43}\"))) {\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"PUT $key = $value\")\n+ }\n+ }\n+ if (json.length() >= 5000 || approxSize > 10000000) {\n+ sendBatch.accept(json)\n+ json = JSONArray()\n+ approxSize = 0\n+ }\n+ }\n+ if (json.length() > 0) {\n+ sendBatch.accept(json)\n+ }\n+ }\n+\n+ override fun prefetch(key: String?) {}\n+\n+ override val storeCache: IDeserializingKeyValueStore\n+ get() = cache\n+\n+ inner class SseListener(val key: String?, val keyListener: IKeyListener?) {\n+ private val notificationLock = Any()\n+ private var lastValue: String? = null\n+ private val sse = arrayOfNulls<Sse>(2)\n+ private var disposed = false\n+ fun dispose() {\n+ if (disposed) {\n+ return\n+ }\n+ disposed = true\n+ for (i in sse.indices) {\n+ if (sse[i] != null) {\n+ sse[i]!!.sse.close()\n+ sse[i] = null\n+ }\n+ }\n+ }\n+\n+ @Synchronized\n+ fun ensureConnected() {\n+ if (disposed) {\n+ return\n+ }\n+ for (i in sse.indices) {\n+ if (sse[i] == null) {\n+ continue\n+ }\n+ if (sse[i]!!.birth > System.currentTimeMillis()) {\n+ sse[i]!!.birth = System.currentTimeMillis()\n+ }\n+ if (!(sse[i]!!.sse.isOpen)) {\n+ sse[i] = null\n+ }\n+ }\n+ for (i in sse.indices) {\n+ // To support rebalancing after scaling the cluster a connection shouldn't be open for too long.\n+ if (sse[i] != null && sse[i]!!.age > 20000) {\n+ sse[i]!!.sse.close()\n+ sse[i] = null\n+ }\n+ }\n+ val youngest = Stream.of(*sse).filter(Predicate<Sse?> { obj: Sse? -> Objects.nonNull(obj) }).mapToLong(ToLongFunction<Sse?> { it: Sse? -> it!!.birth }).reduce(0L) { a: Long, b: Long -> Math.max(a, b) }\n+ if (System.currentTimeMillis() - youngest < 5000) {\n+ return\n+ }\n+ for (i in sse.indices) {\n+ if (sse[i] != null) {\n+ continue\n+ }\n+ val url = baseUrl + \"subscribe/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)\n+ if (LOG.isTraceEnabled) {\n+ LOG.trace(\"Connecting to $url\")\n+ }\n+ val target = client.target(url)\n+ sse[i] = Sse(SseEventSource.target(target).reconnectingEvery(1, TimeUnit.SECONDS).build())\n+ sse[i]!!.sse.register(Consumer { event ->\n+ val value = event.readData()\n+ synchronized(notificationLock) {\n+ if (!((value == lastValue))) {\n+ lastValue = value\n+ keyListener!!.changed(key, value)\n+ }\n+ }\n+ }, object : Consumer<Throwable?> {\n+ override fun accept(ex: Throwable?) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ }\n+ })\n+ if (disposed) {\n+ return\n+ }\n+ sse[i]!!.sse.open()\n+ if (LOG.isTraceEnabled) {\n+ LOG.trace(\"Connected to $url\")\n+ }\n+ break\n+ }\n+ }\n+\n+ inner class Sse(val sse: SseEventSource) {\n+ var birth = System.currentTimeMillis()\n+ val age: Long\n+ get() = System.currentTimeMillis() - birth\n+\n+ }\n+\n+ }\n+\n+ init {\n+ if (isEmptyString(baseUrl)) {\n+ baseUrl = defaultUrl\n+ }\n+ if (!(baseUrl!!.endsWith(\"/\"))) {\n+ baseUrl += \"/\"\n+ }\n+ client = ClientBuilder.newBuilder().register(object : ClientRequestFilter {\n+ @Throws(IOException::class)\n+ override fun filter(ctx: ClientRequestContext) {\n+ ctx.headers.add(HttpHeaders.AUTHORIZATION, \"Bearer $authToken\")\n+ }\n+ }).build()\n+ watchDogTask = fixDelay(1000, object : Runnable {\n+ override fun run() {\n+ var ls: List<SseListener>\n+ synchronized(listeners) { ls = ArrayList(listeners) }\n+ for (l: SseListener in ls) {\n+ try {\n+ l.ensureConnected()\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ }\n+ }\n+ }\n+ })\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "RENAME", "old_path": "model-client/src/main/java/org/modelix/model/client/SharedExecutors.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/SharedExecutors.kt", "diff": "" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate RestWebModelClient
426,504
01.08.2020 13:26:06
-7,200
8956bd43534bfa9f118e109fb3c2905d7e2054e5
translate CLVersion
[ { "change_type": "ADD", "old_path": null, "new_path": "model-client/.idea/uiDesigner.xml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<project version=\"4\">\n+ <component name=\"Palette2\">\n+ <group name=\"Swing\">\n+ <item class=\"com.intellij.uiDesigner.HSpacer\" tooltip-text=\"Horizontal Spacer\" icon=\"/com/intellij/uiDesigner/icons/hspacer.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"1\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"com.intellij.uiDesigner.VSpacer\" tooltip-text=\"Vertical Spacer\" icon=\"/com/intellij/uiDesigner/icons/vspacer.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"1\" anchor=\"0\" fill=\"2\" />\n+ </item>\n+ <item class=\"javax.swing.JPanel\" icon=\"/com/intellij/uiDesigner/icons/panel.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JScrollPane\" icon=\"/com/intellij/uiDesigner/icons/scrollPane.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"7\" hsize-policy=\"7\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JButton\" icon=\"/com/intellij/uiDesigner/icons/button.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"0\" fill=\"1\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"Button\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JRadioButton\" icon=\"/com/intellij/uiDesigner/icons/radioButton.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"RadioButton\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JCheckBox\" icon=\"/com/intellij/uiDesigner/icons/checkBox.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"CheckBox\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JLabel\" icon=\"/com/intellij/uiDesigner/icons/label.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"Label\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JTextField\" icon=\"/com/intellij/uiDesigner/icons/textField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JPasswordField\" icon=\"/com/intellij/uiDesigner/icons/passwordField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JFormattedTextField\" icon=\"/com/intellij/uiDesigner/icons/formattedTextField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTextArea\" icon=\"/com/intellij/uiDesigner/icons/textArea.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTextPane\" icon=\"/com/intellij/uiDesigner/icons/textPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JEditorPane\" icon=\"/com/intellij/uiDesigner/icons/editorPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JComboBox\" icon=\"/com/intellij/uiDesigner/icons/comboBox.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"2\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JTable\" icon=\"/com/intellij/uiDesigner/icons/table.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JList\" icon=\"/com/intellij/uiDesigner/icons/list.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"2\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTree\" icon=\"/com/intellij/uiDesigner/icons/tree.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTabbedPane\" icon=\"/com/intellij/uiDesigner/icons/tabbedPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"200\" height=\"200\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JSplitPane\" icon=\"/com/intellij/uiDesigner/icons/splitPane.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"200\" height=\"200\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JSpinner\" icon=\"/com/intellij/uiDesigner/icons/spinner.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JSlider\" icon=\"/com/intellij/uiDesigner/icons/slider.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JSeparator\" icon=\"/com/intellij/uiDesigner/icons/separator.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JProgressBar\" icon=\"/com/intellij/uiDesigner/icons/progressbar.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JToolBar\" icon=\"/com/intellij/uiDesigner/icons/toolbar.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\">\n+ <preferred-size width=\"-1\" height=\"20\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JToolBar$Separator\" icon=\"/com/intellij/uiDesigner/icons/toolbarSeparator.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JScrollBar\" icon=\"/com/intellij/uiDesigner/icons/scrollbar.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"0\" anchor=\"0\" fill=\"2\" />\n+ </item>\n+ </group>\n+ </component>\n+</project>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLVersion.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.jetbrains.annotations.NotNull;\n-import org.modelix.model.operations.IOperation;\n-import org.modelix.model.persistent.CPOperationsList;\n-import org.modelix.model.persistent.CPVersion;\n-\n-import java.util.Arrays;\n-\n-public class CLVersion {\n- public static CLVersion loadFromHash(String hash, IDeserializingKeyValueStore store) {\n- CPVersion data = store.get(hash, CPVersion::deserialize);\n- return (data == null ? null : new CLVersion(data, store));\n- }\n-\n- private IDeserializingKeyValueStore store;\n- private CPVersion data;\n-\n- public CLVersion(long id, String time, String author, String treeHash, String previousVersion, IOperation[] operations, IDeserializingKeyValueStore store) {\n- this.store = store;\n- if (operations.length <= 10) {\n- this.data = new CPVersion(id, time, author, treeHash, previousVersion, operations, null, operations.length);\n- } else {\n- CPOperationsList opsList = new CPOperationsList(operations);\n- IDeserializingKeyValueStore_extensions.put(store, opsList, opsList.serialize());\n- this.data = new CPVersion(id, time, author, treeHash, previousVersion, null, opsList.getHash(), operations.length);\n- }\n- IDeserializingKeyValueStore_extensions.put(store, data, data.serialize());\n- }\n-\n- public CLVersion(String hash, IDeserializingKeyValueStore store) {\n- this(store.get(hash, CPVersion::deserialize), store);\n- }\n-\n- public CLVersion(@NotNull CPVersion data, IDeserializingKeyValueStore store) {\n- if (data == null) {\n- throw new NullPointerException(\"data is null\");\n- }\n- this.data = data;\n- this.store = store;\n- }\n-\n- public String getAuthor() {\n- return data.author;\n- }\n-\n- public long getId() {\n- return data.id;\n- }\n-\n- public String getTime() {\n- return data.time;\n- }\n-\n- public String getHash() {\n- return data.getHash();\n- }\n-\n- public String getPreviousHash() {\n- return data.previousVersion;\n- }\n-\n- public String getTreeHash() {\n- return data.treeHash;\n- }\n-\n- public CLTree getTree() {\n- return new CLTree(getTreeHash(), store);\n- }\n-\n- public CPVersion getData() {\n- return data;\n- }\n-\n- public CLVersion getPreviousVersion() {\n- if (data.previousVersion == null) {\n- return null;\n- }\n- CPVersion previousVersion = store.get(data.previousVersion, CPVersion::deserialize);\n- if (previousVersion == null) {\n- return null;\n- }\n- return new CLVersion(previousVersion, store);\n- }\n-\n- public Iterable<IOperation> getOperations() {\n- IOperation[] ops = data.operationsHash == null\n- ? data.operations\n- : store.get(data.operationsHash, CPOperationsList::deserialize).operations;\n- return Arrays.stream(ops)::iterator;\n- }\n-\n- public int getNumberOfOperations() {\n- return data.numberOfOperations;\n- }\n-\n- public boolean operationsInlined() {\n- return data.operations != null;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLVersion.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.operations.IOperation\n+import org.modelix.model.persistent.CPOperationsList\n+import org.modelix.model.persistent.CPVersion\n+import java.util.*\n+\n+class CLVersion {\n+ private var store: IDeserializingKeyValueStore\n+ var data: CPVersion? = null\n+ private set\n+\n+ constructor(id: Long, time: String?, author: String?, treeHash: String?, previousVersion: String?, operations: Array<IOperation?>, store: IDeserializingKeyValueStore) {\n+ this.store = store\n+ if (operations.size <= 10) {\n+ data = CPVersion(id, time, author, treeHash, previousVersion, operations, null, operations.size)\n+ } else {\n+ val opsList = CPOperationsList(operations)\n+ IDeserializingKeyValueStore_extensions.put(store, opsList, opsList.serialize())\n+ data = CPVersion(id, time, author, treeHash, previousVersion, null, opsList.hash, operations.size)\n+ }\n+ IDeserializingKeyValueStore_extensions.put(store, data, data!!.serialize())\n+ }\n+\n+ constructor(hash: String?, store: IDeserializingKeyValueStore) : this(store.get<CPVersion>(hash) { input: String? -> CPVersion.deserialize(input) }, store) {}\n+ constructor(data: CPVersion, store: IDeserializingKeyValueStore) {\n+ if (data == null) {\n+ throw NullPointerException(\"data is null\")\n+ }\n+ this.data = data\n+ this.store = store\n+ }\n+\n+ val author: String\n+ get() = data!!.author\n+\n+ val id: Long\n+ get() = data!!.id\n+\n+ val time: String\n+ get() = data!!.time\n+\n+ val hash: String\n+ get() = data!!.hash\n+\n+ val previousHash: String\n+ get() = data!!.previousVersion\n+\n+ val treeHash: String\n+ get() = data!!.treeHash\n+\n+ val tree: CLTree\n+ get() = CLTree(treeHash, store)\n+\n+ val previousVersion: CLVersion?\n+ get() {\n+ if (data!!.previousVersion == null) {\n+ return null\n+ }\n+ val previousVersion = store.get(data!!.previousVersion) { input: String? -> CPVersion.deserialize(input) }\n+ ?: return null\n+ return CLVersion(previousVersion, store)\n+ }\n+\n+ val operations: Iterable<IOperation>\n+ get() {\n+ val ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash) { input: String? -> CPOperationsList.deserialize(input) }.operations\n+ return Iterable { Arrays.stream(ops).iterator() }\n+ }\n+\n+ val numberOfOperations: Int\n+ get() = data!!.numberOfOperations\n+\n+ fun operationsInlined(): Boolean {\n+ return data!!.operations != null\n+ }\n+\n+ companion object {\n+ @JvmStatic\n+ fun loadFromHash(hash: String?, store: IDeserializingKeyValueStore): CLVersion? {\n+ val data = store.get(hash) { input: String? -> CPVersion.deserialize(input) }\n+ return data?.let { CLVersion(it, store) }\n+ }\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CLVersion
426,504
01.08.2020 13:26:48
-7,200
28b32630f3f5c1b050d0168d7ef45cd4d184a080
translate VersionChangeDetector
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/VersionChangeDetector.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.apache.log4j.Logger;\n-import org.apache.log4j.LogManager;\n-\n-import java.util.concurrent.ScheduledFuture;\n-import java.util.Objects;\n-import org.apache.log4j.Level;\n-import org.modelix.model.IKeyListener;\n-import org.modelix.model.IKeyValueStore;\n-\n-public abstract class VersionChangeDetector {\n- private static final Logger LOG = LogManager.getLogger(VersionChangeDetector.class);\n- private IKeyListener keyListener;\n- private IKeyValueStore store;\n- private String lastKnownVersion;\n- private final String key;\n- private ScheduledFuture<?> pollingTask;\n-\n- public VersionChangeDetector(final IKeyValueStore store, final String key) {\n- this.store = store;\n- this.key = key;\n- keyListener = new IKeyListener() {\n- @Override\n- public void changed(String key, String versionHash) {\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"Listener received new version \" + versionHash);\n- }\n- versionChanged(versionHash);\n- }\n- };\n- SharedExecutors.FIXED.execute(new Runnable() {\n- public void run() {\n- store.listen(key, keyListener);\n- }\n- });\n- pollingTask = SharedExecutors.fixDelay(3000, new Runnable() {\n- public void run() {\n- String version = store.get(key);\n- if (Objects.equals(version, lastKnownVersion)) {\n- return;\n- }\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"New version detected by polling: \" + version);\n- }\n- versionChanged(version);\n- }\n- });\n- }\n-\n- private void versionChanged(String newVersion) {\n- if (Objects.equals(newVersion, lastKnownVersion)) {\n- return;\n- }\n- try {\n- processVersionChange(lastKnownVersion, newVersion);\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- }\n- lastKnownVersion = newVersion;\n- }\n-\n- protected abstract void processVersionChange(String oldVersion, String newVersion);\n-\n- public void dispose() {\n- pollingTask.cancel(false);\n- store.removeListener(key, keyListener);\n- }\n-\n- public String getLastVersionHash() {\n- return lastKnownVersion;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/client/VersionChangeDetector.kt", "diff": "+package org.modelix.model.client\n+\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import org.modelix.model.IKeyListener\n+import org.modelix.model.IKeyValueStore\n+import org.modelix.model.client.SharedExecutors.fixDelay\n+import java.util.concurrent.ScheduledFuture\n+\n+abstract class VersionChangeDetector(private val store: IKeyValueStore, private val key: String) {\n+ private val keyListener: IKeyListener\n+ var lastVersionHash: String? = null\n+ private set\n+ private val pollingTask: ScheduledFuture<*>\n+ private fun versionChanged(newVersion: String?) {\n+ if (newVersion == lastVersionHash) {\n+ return\n+ }\n+ try {\n+ processVersionChange(lastVersionHash, newVersion)\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ }\n+ lastVersionHash = newVersion\n+ }\n+\n+ protected abstract fun processVersionChange(oldVersion: String?, newVersion: String?)\n+ fun dispose() {\n+ pollingTask.cancel(false)\n+ store.removeListener(key, keyListener)\n+ }\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(VersionChangeDetector::class.java)\n+ }\n+\n+ init {\n+ keyListener = object : IKeyListener {\n+ override fun changed(key: String?, versionHash: String?) {\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"Listener received new version $versionHash\")\n+ }\n+ versionChanged(versionHash)\n+ }\n+ }\n+ SharedExecutors.FIXED.execute { store.listen(key, keyListener) }\n+ pollingTask = fixDelay(3000, object : Runnable {\n+ override fun run() {\n+ val version = store[key]\n+ if (version == lastVersionHash) {\n+ return\n+ }\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"New version detected by polling: $version\")\n+ }\n+ versionChanged(version)\n+ }\n+ })\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate VersionChangeDetector
426,504
01.08.2020 13:36:18
-7,200
703a66b69822504569251090bc96334441068b51
complete migration of client package
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/client/ReplicatedTree.java", "new_path": null, "diff": "-package org.modelix.model.client;\n-\n-import org.modelix.model.api.IBranch;\n-import org.modelix.model.api.IBranchListener;\n-import org.modelix.model.api.ITree;\n-import org.modelix.model.api.IWriteTransaction;\n-import org.modelix.model.api.PBranch;\n-import io.vavr.Tuple2;\n-import org.apache.commons.lang3.mutable.MutableObject;\n-import org.apache.log4j.Level;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.jetbrains.annotations.NotNull;\n-import org.modelix.model.VersionMerger;\n-import org.modelix.model.lazy.CLTree;\n-import org.modelix.model.lazy.CLVersion;\n-import org.modelix.model.lazy.TreeId;\n-import org.modelix.model.operations.IAppliedOperation;\n-import org.modelix.model.operations.IOperation;\n-import org.modelix.model.operations.OTBranch;\n-\n-import java.time.LocalDateTime;\n-import java.util.List;\n-import java.util.Objects;\n-import java.util.concurrent.ScheduledFuture;\n-import java.util.concurrent.atomic.AtomicBoolean;\n-import java.util.function.Supplier;\n-\n-public class ReplicatedTree {\n- private static final Logger LOG = LogManager.getLogger(ReplicatedTree.class);\n-\n- private IModelClient client;\n- private TreeId treeId;\n- private String branchName;\n- private Supplier<String> user;\n- private IBranch localBranch;\n- private OTBranch localOTBranch;\n-\n- private final Object mergeLock = new Object();\n- private VersionMerger merger;\n- private volatile CLVersion localVersion;\n- private volatile CLVersion remoteVersion;\n-\n- private VersionChangeDetector versionChangeDetector;\n- private final AtomicBoolean isEditing = new AtomicBoolean(false);\n- private boolean disposed = false;\n- private int divergenceTime = 0;\n- private ScheduledFuture<?> convergenceWatchdog;\n-\n- public ReplicatedTree(final IModelClient client, final TreeId treeId, @NotNull final String branchName, Supplier<String> user) {\n- this.client = client;\n- this.treeId = treeId;\n- this.branchName = branchName;\n- this.user = user;\n-\n- String versionHash = client.get(treeId.getBranchKey(branchName));\n- CLVersion initialVersion = CLVersion.loadFromHash(versionHash, client.getStoreCache());\n- final MutableObject<CLTree> initialTree = new MutableObject<>();\n- if (initialVersion == null) {\n- initialTree.setValue(new CLTree(treeId, client.getStoreCache()));\n- initialVersion = createVersion(initialTree.getValue(), new IOperation[0], null);\n- client.put(treeId.getBranchKey(this.branchName), initialVersion.getHash());\n- } else {\n- initialTree.setValue(new CLTree(initialVersion.getTreeHash(), client.getStoreCache()));\n- }\n-\n- // prefetch to avoid HTTP request in command listener\n- SharedExecutors.FIXED.execute(() -> initialTree.getValue().getChildren(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE));\n-\n- localVersion = initialVersion;\n- remoteVersion = initialVersion;\n-\n- localBranch = new PBranch(initialTree.getValue());\n- localOTBranch = new OTBranch(localBranch, client.getIdGenerator());\n- merger = new VersionMerger(client.getStoreCache(), client.getIdGenerator());\n- versionChangeDetector = new VersionChangeDetector(client, treeId.getBranchKey(this.branchName)) {\n- @Override\n- protected void processVersionChange(String oldVersionHash, String newVersionHash) {\n- if (disposed) {\n- return;\n- }\n- if ((newVersionHash == null || newVersionHash.length() == 0)) {\n- return;\n- }\n- if (Objects.equals(newVersionHash, getHash(remoteVersion))) {\n- return;\n- }\n- final CLVersion newRemoteVersion = CLVersion.loadFromHash(newVersionHash, client.getStoreCache());\n- if (newRemoteVersion == null) {\n- return;\n- }\n-\n- final MutableObject<CLVersion> localBase = new MutableObject<>();\n- synchronized (mergeLock) {\n- localBase.setValue(localVersion);\n- remoteVersion = newRemoteVersion;\n- }\n-\n- Supplier<Boolean> doMerge = () -> {\n- CLVersion mergedVersion;\n- try {\n- mergedVersion = merger.mergeChange(localBase.getValue(), newRemoteVersion);\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(String.format(\"Merged remote %s with local %s -> %s\",\n- newRemoteVersion.getHash(),\n- localBase.getValue().getHash(),\n- mergedVersion.getHash()));\n- }\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- mergedVersion = newRemoteVersion;\n- }\n- CLTree mergedTree = mergedVersion.getTree();\n- synchronized (mergeLock) {\n- remoteVersion = mergedVersion;\n- if (localVersion == localBase.getValue()) {\n- writeLocalVersion(mergedVersion);\n- writeRemoteVersion(mergedVersion);\n- return true;\n- } else {\n- localBase.setValue(localVersion);\n- return false;\n- }\n- }\n- };\n-\n- // Avoid locking during the merge as it may require communication with the model server\n- for (int mergeAttempt = 0; mergeAttempt < 3; mergeAttempt++) {\n- if (doMerge.get()) {\n- return;\n- }\n- }\n- synchronized (mergeLock) {\n- localBase.setValue(localVersion);\n- doMerge.get();\n- }\n- }\n- };\n-\n- localOTBranch.addListener(new IBranchListener() {\n- @Override\n- public void treeChanged(ITree oldTree, ITree newTree) {\n- if (disposed) {\n- return;\n- }\n- if (isEditing.get()) {\n- return;\n- }\n- SharedExecutors.FIXED.execute(() -> {\n- if (isEditing.get()) {\n- return;\n- }\n- createAndMergeLocalVersion();\n- });\n- }\n- });\n-\n- convergenceWatchdog = SharedExecutors.fixDelay(1000, new Runnable() {\n- public void run() {\n- String localHash = localVersion == null ? null : localVersion.getHash();\n- String remoteHash = remoteVersion == null ? null : remoteVersion.getHash();\n- if (Objects.equals(localHash, remoteHash)) {\n- divergenceTime = 0;\n- } else {\n- divergenceTime++;\n- }\n- if (divergenceTime > 5) {\n- synchronized (mergeLock) {\n- divergenceTime = 0;\n- }\n- }\n- }\n- });\n- }\n-\n- public IBranch getBranch() {\n- checkDisposed();\n- return localOTBranch;\n- }\n-\n- public CLVersion getVersion() {\n- return localVersion;\n- }\n-\n- /**\n- * Call this at the beginning of an edit operation in the editor\n- */\n- public void startEdit() {\n- isEditing.set(true);\n- }\n-\n- /**\n- * Call this at the end of an edit operation in the editor\n- */\n- public void endEdit() {\n- if (disposed) return;\n- try {\n- synchronized (mergeLock) {\n- deleteDetachedNodes();\n- createAndMergeLocalVersion();\n- }\n- } finally {\n- isEditing.set(false);\n- }\n- }\n-\n- protected void deleteDetachedNodes() {\n- boolean hasDetachedNodes = localOTBranch.computeRead(() -> localOTBranch.getTransaction()\n- .getChildren(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE).iterator().hasNext());\n- // avoid unnecessary write\n- if (hasDetachedNodes) {\n- localOTBranch.runWrite(() -> {\n- // clear detached nodes\n- IWriteTransaction t = localOTBranch.getWriteTransaction();\n- t.getChildren(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE).forEach(t::deleteNode);\n- });\n- }\n- }\n-\n- protected void createAndMergeLocalVersion() {\n- checkDisposed();\n-\n- Tuple2<List<IAppliedOperation>, ITree> opsAndTree;\n- CLVersion localBase;\n- final MutableObject<CLVersion> remoteBase = new MutableObject<>();\n- final MutableObject<CLVersion> newLocalVersion = new MutableObject<>();\n- synchronized (mergeLock) {\n- opsAndTree = localOTBranch.getOperationsAndTree();\n- localBase = localVersion;\n- remoteBase.setValue(remoteVersion);\n- IOperation[] ops = opsAndTree._1().stream().map(IAppliedOperation::getOriginalOp).toArray(IOperation[]::new);\n- if (ops.length == 0) {\n- return;\n- }\n- newLocalVersion.setValue(createVersion((CLTree) opsAndTree._2(), ops, localBase.getHash()));\n- localVersion = newLocalVersion.getValue();\n- divergenceTime = 0;\n- }\n-\n- SharedExecutors.FIXED.execute(new Runnable() {\n- public void run() {\n- Supplier<Boolean> doMerge = () -> {\n- CLVersion mergedVersion;\n- try {\n- mergedVersion = merger.mergeChange(remoteBase.getValue(), newLocalVersion.getValue());\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(String.format(\"Merged local %s with remote %s -> %s\",\n- newLocalVersion.getValue().getHash(),\n- remoteBase.getValue().getHash(),\n- mergedVersion.getHash()));\n- }\n- } catch (Exception ex) {\n- if (LOG.isEnabledFor(Level.ERROR)) {\n- LOG.error(\"\", ex);\n- }\n- mergedVersion = newLocalVersion.getValue();\n- }\n-\n- synchronized (mergeLock) {\n- writeLocalVersion(localVersion);\n- if (remoteVersion == remoteBase.getValue()) {\n- writeRemoteVersion(mergedVersion);\n- return true;\n- } else {\n- remoteBase.setValue(remoteVersion);\n- return false;\n- }\n- }\n- };\n-\n- // Avoid locking during the merge as it may require communication with the model server\n- for (int mergeAttempt = 0; mergeAttempt < 3; mergeAttempt++) {\n- if (doMerge.get()) {\n- return;\n- }\n- }\n- synchronized (mergeLock) {\n- remoteBase.setValue(remoteVersion);\n- doMerge.get();\n- }\n- }\n- });\n- }\n-\n- protected void writeRemoteVersion(CLVersion version) {\n- synchronized (mergeLock) {\n- if (!(Objects.equals(remoteVersion.getHash(), version.getHash()))) {\n- remoteVersion = version;\n- client.getAsyncStore().put(treeId.getBranchKey(branchName), version.getHash());\n- }\n- }\n- }\n-\n- protected void writeLocalVersion(final CLVersion version) {\n- synchronized (mergeLock) {\n- if (!(Objects.equals(localVersion.getHash(), version.getHash()))) {\n- localVersion = version;\n- divergenceTime = 0;\n- localBranch.runWrite(() -> {\n- CLTree newTree = version.getTree();\n- CLTree currentTree = (CLTree) localBranch.getTransaction().getTree();\n- if (!(Objects.equals(getHash(newTree), getHash(currentTree)))) {\n- localBranch.getWriteTransaction().setTree(newTree);\n- }\n- });\n- }\n- }\n- }\n-\n- public CLVersion createVersion(CLTree tree, IOperation[] operations, String previousVersion) {\n- checkDisposed();\n- String time = LocalDateTime.now().toString();\n- return new CLVersion(client.getIdGenerator().generate(), time, user.get(), tree.getHash(), previousVersion, operations, client.getStoreCache());\n- }\n-\n- public void dispose() {\n- checkDisposed();\n- disposed = true;\n- versionChangeDetector.dispose();\n- convergenceWatchdog.cancel(false);\n- }\n-\n- public void checkDisposed() {\n- if (disposed) {\n- throw new RuntimeException(\"Already disposed\");\n- }\n- }\n-\n- private static String getHash(CLVersion v) {\n- return v == null ? null : v.getHash();\n- }\n-\n- private static String getHash(CLTree v) {\n- return v == null ? null : v.getHash();\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/client/ReplicatedTree.kt", "diff": "+package org.modelix.model.client\n+\n+import io.vavr.Tuple2\n+import org.apache.commons.lang3.mutable.MutableObject\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import org.modelix.model.VersionMerger\n+import org.modelix.model.api.*\n+import org.modelix.model.client.ReplicatedTree\n+import org.modelix.model.client.SharedExecutors.fixDelay\n+import org.modelix.model.lazy.CLTree\n+import org.modelix.model.lazy.CLVersion\n+import org.modelix.model.lazy.CLVersion.Companion.loadFromHash\n+import org.modelix.model.lazy.TreeId\n+import org.modelix.model.operations.IAppliedOperation\n+import org.modelix.model.operations.IOperation\n+import org.modelix.model.operations.OTBranch\n+import java.time.LocalDateTime\n+import java.util.concurrent.ScheduledFuture\n+import java.util.concurrent.atomic.AtomicBoolean\n+import java.util.function.IntFunction\n+import java.util.function.Supplier\n+\n+class ReplicatedTree(private val client: IModelClient, private val treeId: TreeId, private val branchName: String, private val user: Supplier<String>) {\n+ private val localBranch: IBranch\n+ private val localOTBranch: OTBranch\n+ private val mergeLock = Any()\n+ private val merger: VersionMerger\n+\n+ @Volatile\n+ var version: CLVersion?\n+ private set\n+\n+ @Volatile\n+ private var remoteVersion: CLVersion?\n+ private val versionChangeDetector: VersionChangeDetector\n+ private val isEditing = AtomicBoolean(false)\n+ private var disposed = false\n+ private var divergenceTime = 0\n+ private val convergenceWatchdog: ScheduledFuture<*>\n+ val branch: IBranch\n+ get() {\n+ checkDisposed()\n+ return localOTBranch\n+ }\n+\n+ /**\n+ * Call this at the beginning of an edit operation in the editor\n+ */\n+ fun startEdit() {\n+ isEditing.set(true)\n+ }\n+\n+ /**\n+ * Call this at the end of an edit operation in the editor\n+ */\n+ fun endEdit() {\n+ if (disposed) return\n+ try {\n+ synchronized(mergeLock) {\n+ deleteDetachedNodes()\n+ createAndMergeLocalVersion()\n+ }\n+ } finally {\n+ isEditing.set(false)\n+ }\n+ }\n+\n+ protected fun deleteDetachedNodes() {\n+ val hasDetachedNodes = localOTBranch.computeRead(Supplier<Boolean> {\n+ localOTBranch.transaction!!\n+ .getChildren(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE)!!.iterator().hasNext()\n+ })\n+ // avoid unnecessary write\n+ if (hasDetachedNodes) {\n+ localOTBranch.runWrite(Runnable {\n+\n+ // clear detached nodes\n+ val t: IWriteTransaction = localOTBranch.writeTransaction!!\n+ t.getChildren(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE)!!.forEach { nodeId: Long -> t.deleteNode(nodeId) }\n+ })\n+ }\n+ }\n+\n+ protected fun createAndMergeLocalVersion() {\n+ checkDisposed()\n+ var opsAndTree: Tuple2<List<IAppliedOperation?>, ITree>\n+ var localBase: CLVersion?\n+ val remoteBase = MutableObject<CLVersion?>()\n+ val newLocalVersion = MutableObject<CLVersion>()\n+ synchronized(mergeLock) {\n+ opsAndTree = localOTBranch.operationsAndTree\n+ localBase = version\n+ remoteBase.setValue(remoteVersion)\n+ val ops : Array<IOperation?> = opsAndTree._1.map { it?.originalOp }.toTypedArray()\n+ //val ops: Array<IOperation?> = opsAndTree._1().stream().map(IAppliedOperation::originalOp).toArray(IntFunction<Array<IOperation>> { _Dummy_.__Array__() })\n+ if (ops.size == 0) {\n+ return\n+ }\n+ newLocalVersion.setValue(createVersion(opsAndTree._2() as CLTree, ops, localBase!!.hash))\n+ version = newLocalVersion.value\n+ divergenceTime = 0\n+ }\n+ SharedExecutors.FIXED.execute(object : Runnable {\n+ override fun run() {\n+ val doMerge : Supplier<Boolean> = object : Supplier<Boolean> {\n+ override fun get(): Boolean {\n+\n+ var mergedVersion: CLVersion\n+ try {\n+ mergedVersion = merger.mergeChange(remoteBase.value!!, newLocalVersion.value)\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(String.format(\"Merged local %s with remote %s -> %s\",\n+ newLocalVersion.value.hash,\n+ remoteBase.value!!.hash,\n+ mergedVersion.hash))\n+ }\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ mergedVersion = newLocalVersion.value\n+ }\n+ synchronized(mergeLock) {\n+ writeLocalVersion(version)\n+ if (remoteVersion == remoteBase.value) {\n+ writeRemoteVersion(mergedVersion)\n+ return true\n+ } else {\n+ remoteBase.setValue(remoteVersion)\n+ return false\n+ }\n+ }\n+ }\n+ }\n+\n+ // Avoid locking during the merge as it may require communication with the model server\n+ for (mergeAttempt in 0..2) {\n+ if (doMerge.get()) {\n+ return\n+ }\n+ }\n+ synchronized(mergeLock) {\n+ remoteBase.setValue(remoteVersion)\n+ doMerge.get()\n+ }\n+ }\n+ })\n+ }\n+\n+ protected fun writeRemoteVersion(version: CLVersion) {\n+ synchronized(mergeLock) {\n+ if (remoteVersion!!.hash != version.hash) {\n+ remoteVersion = version\n+ client.asyncStore!!.put(treeId.getBranchKey(branchName), version.hash)\n+ }\n+ }\n+ }\n+\n+ protected fun writeLocalVersion(version: CLVersion?) {\n+ synchronized(mergeLock) {\n+ if (version!!.hash != version.hash) {\n+ this.version = version\n+ divergenceTime = 0\n+ localBranch.runWrite(Runnable {\n+ val newTree = version.tree\n+ val currentTree = localBranch.transaction!!.tree as CLTree?\n+ if (getHash(newTree) != getHash(currentTree)) {\n+ localBranch.writeTransaction!!.tree = newTree\n+ }\n+ })\n+ }\n+ }\n+ }\n+\n+ fun createVersion(tree: CLTree, operations: Array<IOperation?>?, previousVersion: String?): CLVersion {\n+ checkDisposed()\n+ val time = LocalDateTime.now().toString()\n+ return CLVersion(client.idGenerator!!.generate(), time, user.get(), tree.hash, previousVersion, operations!!, client.storeCache!!)\n+ }\n+\n+ fun dispose() {\n+ checkDisposed()\n+ disposed = true\n+ versionChangeDetector.dispose()\n+ convergenceWatchdog.cancel(false)\n+ }\n+\n+ fun checkDisposed() {\n+ if (disposed) {\n+ throw RuntimeException(\"Already disposed\")\n+ }\n+ }\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(ReplicatedTree::class.java)\n+ private fun getHash(v: CLVersion?): String? {\n+ return v?.hash\n+ }\n+\n+ private fun getHash(v: CLTree?): String? {\n+ return v?.hash\n+ }\n+ }\n+\n+ init {\n+ val versionHash = client[treeId.getBranchKey(branchName)]\n+ var initialVersion = loadFromHash(versionHash, client.storeCache!!)\n+ val initialTree = MutableObject<CLTree>()\n+ if (initialVersion == null) {\n+ initialTree.setValue(CLTree(treeId, client.storeCache))\n+ initialVersion = createVersion(initialTree.value, arrayOfNulls(0), null)\n+ client.put(treeId.getBranchKey(branchName), initialVersion.hash)\n+ } else {\n+ initialTree.setValue(CLTree(initialVersion.treeHash, client.storeCache))\n+ }\n+\n+ // prefetch to avoid HTTP request in command listener\n+ SharedExecutors.FIXED.execute { initialTree.value.getChildren(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE) }\n+ version = initialVersion\n+ remoteVersion = initialVersion\n+ localBranch = PBranch(initialTree.value)\n+ localOTBranch = OTBranch(localBranch, client.idGenerator)\n+ merger = VersionMerger(client.storeCache!!, client.idGenerator!!)\n+ versionChangeDetector = object : VersionChangeDetector(client, treeId.getBranchKey(branchName)) {\n+ override fun processVersionChange(oldVersionHash: String?, newVersionHash: String?) {\n+ if (disposed) {\n+ return\n+ }\n+ if (newVersionHash == null || newVersionHash.length == 0) {\n+ return\n+ }\n+ if (newVersionHash == getHash(remoteVersion)) {\n+ return\n+ }\n+ val newRemoteVersion = loadFromHash(newVersionHash, client.storeCache!!) ?: return\n+ val localBase = MutableObject<CLVersion?>()\n+ synchronized(mergeLock) {\n+ localBase.setValue(version)\n+ remoteVersion = newRemoteVersion\n+ }\n+ val doMerge = object : Supplier<Boolean> {\n+ override fun get(): Boolean {\n+ var mergedVersion: CLVersion\n+ try {\n+ mergedVersion = merger.mergeChange(localBase.value!!, newRemoteVersion)\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(String.format(\"Merged remote %s with local %s -> %s\",\n+ newRemoteVersion.hash,\n+ localBase.value!!.hash,\n+ mergedVersion.hash))\n+ }\n+ } catch (ex: Exception) {\n+ if (LOG.isEnabledFor(Level.ERROR)) {\n+ LOG.error(\"\", ex)\n+ }\n+ mergedVersion = newRemoteVersion\n+ }\n+ val mergedTree = mergedVersion.tree\n+ synchronized(mergeLock) {\n+ remoteVersion = mergedVersion\n+ if (version == localBase.value) {\n+ writeLocalVersion(mergedVersion)\n+ writeRemoteVersion(mergedVersion)\n+ return true\n+ } else {\n+ localBase.setValue(version)\n+ return false\n+ }\n+ }\n+ }\n+ }\n+\n+ // Avoid locking during the merge as it may require communication with the model server\n+ for (mergeAttempt in 0..2) {\n+ if (doMerge.get()) {\n+ return\n+ }\n+ }\n+ synchronized(mergeLock) {\n+ localBase.setValue(version)\n+ doMerge.get()\n+ }\n+ }\n+ }\n+ localOTBranch.addListener(object : IBranchListener {\n+ override fun treeChanged(oldTree: ITree?, newTree: ITree?) {\n+ if (disposed) {\n+ return\n+ }\n+ if (isEditing.get()) {\n+ return\n+ }\n+ SharedExecutors.FIXED.execute {\n+ if (isEditing.get()) {\n+ return@execute\n+ }\n+ createAndMergeLocalVersion()\n+ }\n+ }\n+ })\n+ convergenceWatchdog = fixDelay(1000, object : Runnable {\n+ override fun run() {\n+ val localHash = if (version == null) null else version!!.hash\n+ val remoteHash = if (remoteVersion == null) null else remoteVersion!!.hash\n+ if (localHash == remoteHash) {\n+ divergenceTime = 0\n+ } else {\n+ divergenceTime++\n+ }\n+ if (divergenceTime > 5) {\n+ synchronized(mergeLock) { divergenceTime = 0 }\n+ }\n+ }\n+ })\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
complete migration of client package
426,504
01.08.2020 13:39:36
-7,200
8806e059527a43fa356839094105be8a36c40f03
migrate IPersistable
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/IPersistable.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-public interface IPersistable {\n- String calcHash();\n- void serialize();\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/persistent/IPersistable.kt", "diff": "+package org.modelix.model.persistent\n+\n+interface IPersistable {\n+ fun calcHash(): String?\n+ fun serialize()\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
migrate IPersistable
426,504
01.08.2020 13:45:23
-7,200
6f396a4390a85a40afeb3bba02211c0855ea737a
translate KeyValueStoreCache
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/KeyValueStoreCache.java", "new_path": null, "diff": "-package org.modelix.model;\n-\n-import org.apache.commons.collections4.map.LRUMap;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.modelix.model.util.StreamUtils;\n-import org.modelix.model.persistent.HashUtil;\n-\n-import java.util.ArrayList;\n-import java.util.Arrays;\n-import java.util.Collections;\n-import java.util.HashSet;\n-import java.util.Iterator;\n-import java.util.LinkedHashMap;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.Set;\n-import java.util.stream.Collectors;\n-\n-public class KeyValueStoreCache implements IKeyValueStore {\n- private static final Logger LOG = LogManager.getLogger(KeyValueStoreCache.class);\n-\n- private IKeyValueStore store;\n- private Map<String, String> cache = Collections.synchronizedMap(new LRUMap<>(300000));\n- private final Set<String> pendingPrefetches = new HashSet<>();\n- private final List<GetRequest> activeRequests = new ArrayList<>();\n-\n- public KeyValueStoreCache(IKeyValueStore store) {\n- this.store = store;\n- }\n-\n- @Override\n- public void prefetch(String rootKey) {\n- Set<String> processedKeys = new HashSet<>();\n- processedKeys.add(rootKey);\n- List<String> newKeys = Arrays.asList(rootKey);\n- while (!newKeys.isEmpty() && processedKeys.size() + newKeys.size() <= 100000) {\n- synchronized (pendingPrefetches) {\n- newKeys.remove(pendingPrefetches);\n- }\n- List<String> currentKeys = newKeys;\n- newKeys = new ArrayList<>();\n- Map<String, String> loadedEntries;\n- synchronized (pendingPrefetches) {\n- pendingPrefetches.addAll(currentKeys);\n- }\n- try {\n- loadedEntries = getAll(currentKeys);\n- for (var entry : loadedEntries.entrySet()) {\n- processedKeys.add(entry.getKey());\n- for (String childKey : HashUtil.extractSha256(entry.getValue())) {\n- if (processedKeys.contains(childKey)) {\n- continue;\n- }\n- newKeys.add(childKey);\n- }\n- }\n- } finally {\n- pendingPrefetches.removeAll(currentKeys);\n- }\n- }\n- }\n-\n- @Override\n- public String get(String key) {\n- return getAll(Collections.singleton(key)).get(key);\n- }\n-\n- @Override\n- public Map<String, String> getAll(Iterable<String> keys_) {\n- List<String> remainingKeys = StreamUtils.INSTANCE.toStream(keys_).collect(Collectors.toList());\n- Map<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\n- synchronized (cache) {\n- Iterator<String> itr = remainingKeys.iterator();\n- while (itr.hasNext()) {\n- String key = itr.next();\n- String value = cache.get(key);\n- // always put even if null to have the same order in the linked hash map as in the input\n- result.put(key, value);\n- if (value != null) {\n- itr.remove();\n- }\n- }\n- }\n-\n- if (!remainingKeys.isEmpty()) {\n- List<GetRequest> requiredRequest = new ArrayList<>();\n- GetRequest newRequest = null;\n- synchronized (activeRequests) {\n- for (final GetRequest r : activeRequests) {\n- if (remainingKeys.stream().anyMatch(r.keys::contains)) {\n- if (LOG.isDebugEnabled()) {\n- Set<String> intersection = StreamUtils.INSTANCE.intersection(remainingKeys.stream(), r.keys);\n- LOG.debug(\"Reusing an active request: \" + intersection.stream().findFirst().orElse(null) + \" (\" + intersection.size() + \")\");\n- }\n- requiredRequest.add(r);\n- remainingKeys.removeAll(r.keys);\n- }\n- }\n- if (!remainingKeys.isEmpty()) {\n- newRequest = new GetRequest(new HashSet<>(remainingKeys));\n- requiredRequest.add(newRequest);\n- activeRequests.add(newRequest);\n- }\n- }\n-\n- if (newRequest != null) {\n- try {\n- newRequest.execute();\n- } finally {\n- synchronized (activeRequests) {\n- activeRequests.remove(newRequest);\n- }\n- }\n- }\n-\n- for (GetRequest req : requiredRequest) {\n- Map<String, String> reqResult = req.waitForResult();\n- for (var entry : reqResult.entrySet()) {\n- if (result.containsKey(entry.getKey())) {\n- result.put(entry.getKey(), entry.getValue());\n- }\n- }\n- }\n- }\n-\n- return result;\n- }\n-\n- @Override\n- public void listen(final String key, final IKeyListener listener) {\n- store.listen(key, listener);\n- }\n-\n- @Override\n- public void put(String key, String value) {\n- cache.put(key, value);\n- store.put(key, value);\n- }\n-\n- @Override\n- public void putAll(Map<String, String> entries) {\n- entries.forEach((key, value) -> cache.put(key, value));\n- store.putAll(entries);\n- }\n-\n- @Override\n- public void removeListener(final String key, final IKeyListener listener) {\n- store.removeListener(key, listener);\n- }\n-\n- private class GetRequest {\n- private final Set<String> keys;\n- private Map<String, String> result;\n- private Exception exception;\n-\n- public GetRequest(Set<String> keys) {\n- this.keys = keys;\n- }\n-\n- public void execute() {\n- try {\n- Map<String, String> entriesFromStore = store.getAll(keys);\n- for (var entry : entriesFromStore.entrySet()) {\n- cache.put(entry.getKey(), entry.getValue());\n- }\n- putResult(entriesFromStore);\n- } catch (Exception ex) {\n- putException(ex);\n- }\n- }\n-\n- public synchronized void putException(Exception ex) {\n- this.exception = ex;\n- this.notifyAll();\n- }\n-\n- public synchronized void putResult(Map<String, String> result) {\n- this.result = result;\n- this.notifyAll();\n- }\n-\n- public synchronized Map<String, String> waitForResult() {\n- while (result == null && exception == null) {\n- try {\n- this.wait();\n- } catch (InterruptedException ex) {\n- throw new RuntimeException();\n- }\n- }\n- if (result != null) {\n- return result;\n- } else {\n- throw new RuntimeException(exception);\n- }\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/KeyValueStoreCache.kt", "diff": "+package org.modelix.model\n+\n+import org.apache.commons.collections4.map.LRUMap\n+import org.apache.log4j.LogManager\n+import org.modelix.model.persistent.HashUtil\n+import org.modelix.model.util.StreamUtils.intersection\n+import org.modelix.model.util.StreamUtils.toStream\n+import java.util.*\n+import java.util.concurrent.locks.ReentrantLock\n+import java.util.stream.Collectors\n+\n+class KeyValueStoreCache(private val store: IKeyValueStore) : IKeyValueStore {\n+ private val cache = Collections.synchronizedMap(LRUMap<String?, String?>(300000))\n+ private val pendingPrefetches: MutableSet<String?> = HashSet()\n+ private val activeRequests: MutableList<GetRequest> = ArrayList()\n+ override fun prefetch(rootKey: String?) {\n+ val processedKeys: MutableSet<String?> = HashSet()\n+ processedKeys.add(rootKey)\n+ var newKeys : MutableList<String?> = Arrays.asList(rootKey).toMutableList()\n+ while (!newKeys.isEmpty() && processedKeys.size + newKeys.size <= 100000) {\n+ synchronized(pendingPrefetches) { newKeys.removeAll(pendingPrefetches) }\n+ val currentKeys = newKeys\n+ newKeys = ArrayList()\n+ var loadedEntries: Map<String?, String?>?\n+ synchronized(pendingPrefetches) { pendingPrefetches.addAll(currentKeys) }\n+ try {\n+ loadedEntries = getAll(currentKeys)\n+ for ((key, value) in loadedEntries!!) {\n+ processedKeys.add(key)\n+ for (childKey in HashUtil.extractSha256(value)) {\n+ if (processedKeys.contains(childKey)) {\n+ continue\n+ }\n+ newKeys.add(childKey)\n+ }\n+ }\n+ } finally {\n+ pendingPrefetches.removeAll(currentKeys)\n+ }\n+ }\n+ }\n+\n+ override fun get(key: String?): String? {\n+ return getAll(setOf(key))!![key]\n+ }\n+\n+ override fun getAll(keys_: Iterable<String?>?): Map<String?, String?>? {\n+ val remainingKeys = toStream(keys_!!).collect(Collectors.toList())\n+ val result: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ synchronized(cache) {\n+ val itr = remainingKeys.iterator()\n+ while (itr.hasNext()) {\n+ val key = itr.next()\n+ val value = cache[key]\n+ // always put even if null to have the same order in the linked hash map as in the input\n+ result[key] = value\n+ if (value != null) {\n+ itr.remove()\n+ }\n+ }\n+ }\n+ if (!remainingKeys.isEmpty()) {\n+ val requiredRequest: MutableList<GetRequest> = ArrayList()\n+ var newRequest: GetRequest? = null\n+ synchronized(activeRequests) {\n+ for (r in activeRequests) {\n+ if (remainingKeys.stream().anyMatch { o: String? -> r.keys.contains(o) }) {\n+ if (LOG.isDebugEnabled) {\n+ val intersection = intersection(remainingKeys.stream(), r.keys)\n+ LOG.debug(\"Reusing an active request: \" + intersection.stream().findFirst().orElse(null) + \" (\" + intersection.size + \")\")\n+ }\n+ requiredRequest.add(r)\n+ remainingKeys.removeAll(r.keys)\n+ }\n+ }\n+ if (!remainingKeys.isEmpty()) {\n+ newRequest = GetRequest(HashSet(remainingKeys))\n+ requiredRequest.add(newRequest!!)\n+ activeRequests.add(newRequest!!)\n+ }\n+ }\n+ if (newRequest != null) {\n+ try {\n+ newRequest!!.execute()\n+ } finally {\n+ synchronized(activeRequests) { activeRequests.remove(newRequest!!) }\n+ }\n+ }\n+ for (req in requiredRequest) {\n+ val reqResult = req.waitForResult()\n+ for ((key, value) in reqResult) {\n+ if (result.containsKey(key)) {\n+ result[key] = value\n+ }\n+ }\n+ }\n+ }\n+ return result\n+ }\n+\n+ override fun listen(key: String?, listener: IKeyListener?) {\n+ store.listen(key, listener)\n+ }\n+\n+ override fun put(key: String?, value: String?) {\n+ cache[key] = value\n+ store.put(key, value)\n+ }\n+\n+ override fun putAll(entries: Map<String?, String?>?) {\n+ entries!!.forEach { (key: String?, value: String?) -> cache[key] = value }\n+ store.putAll(entries)\n+ }\n+\n+ override fun removeListener(key: String?, listener: IKeyListener?) {\n+ store.removeListener(key, listener)\n+ }\n+\n+ private inner class GetRequest(val keys: Set<String?>) {\n+ private var result: Map<String?, String?>? = null\n+ private var exception: Exception? = null\n+ fun execute() {\n+ try {\n+ val entriesFromStore = store.getAll(keys)\n+ for ((key, value) in entriesFromStore!!) {\n+ cache[key] = value\n+ }\n+ putResult(entriesFromStore)\n+ } catch (ex: Exception) {\n+ putException(ex)\n+ }\n+ }\n+\n+ private val lock = ReentrantLock()\n+ private val condition = lock.newCondition()\n+\n+ @Synchronized\n+ fun putException(ex: Exception?) {\n+ exception = ex\n+ condition.signalAll()\n+ }\n+\n+ @Synchronized\n+ fun putResult(result: Map<String?, String?>?) {\n+ this.result = result\n+ condition.signalAll()\n+ }\n+\n+ @Synchronized\n+ fun waitForResult(): Map<String?, String?> {\n+ while (result == null && exception == null) {\n+ try {\n+ condition.await()\n+ } catch (ex: InterruptedException) {\n+ throw RuntimeException()\n+ }\n+ }\n+ return if (result != null) {\n+ result!!\n+ } else {\n+ throw RuntimeException(exception)\n+ }\n+ }\n+\n+ }\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(KeyValueStoreCache::class.java)\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate KeyValueStoreCache
426,504
01.08.2020 13:46:18
-7,200
f96353463055207225550c5e1923319f15e73bc0
translate CustomPMap
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/util/pmap/CustomPMap.java", "new_path": null, "diff": "-package org.modelix.model.util.pmap;\n-\n-public interface CustomPMap<K, V> {\n- CustomPMap<K, V> put(K key, V value);\n- V get(K key);\n- CustomPMap<K, V> remove(K key);\n- Iterable<K> keys();\n- Iterable<V> values();\n- boolean containsKey(K key);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/util/pmap/CustomPMap.kt", "diff": "+package org.modelix.model.util.pmap\n+\n+interface CustomPMap<K, V> {\n+ fun put(key: K, value: V): CustomPMap<K, V>?\n+ operator fun get(key: K): V\n+ fun remove(key: K): CustomPMap<K, V>?\n+ fun keys(): Iterable<K>?\n+ fun values(): Iterable<V>?\n+ fun containsKey(key: K): Boolean\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CustomPMap
426,504
01.08.2020 14:21:53
-7,200
79bfd3cb6c7f31d44732051816879ff69390f1b7
translate BulkQuery
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import io.vavr.Tuple;\n-import io.vavr.Tuple3;\n-import org.apache.commons.lang3.mutable.MutableInt;\n-\n-import java.util.ArrayList;\n-import java.util.Arrays;\n-import java.util.Collections;\n-import java.util.HashMap;\n-import java.util.Iterator;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.function.Consumer;\n-import java.util.function.Function;\n-import java.util.stream.Collectors;\n-import java.util.stream.StreamSupport;\n-\n-/**\n- * Not thread safe\n- */\n-public class BulkQuery implements IBulkQuery {\n-\n- private IDeserializingKeyValueStore store;\n- private List<Tuple3<String, Function<String, ?>, Consumer<Object>>> queue = new ArrayList<>();\n- private boolean processing = false;\n-\n- public BulkQuery(IDeserializingKeyValueStore store) {\n- this.store = store;\n- }\n-\n- protected Map<String, Object> executeBulkQuery(Iterable<String> keys, final Map<String, Function<String, ?>> deserializers) {\n- Iterable<Object> values = store.getAll(keys, (key, serialized) -> deserializers.get(key).apply(serialized));\n- Map<String, Object> result = new HashMap<>();\n- {\n- Iterator<String> key_it = keys.iterator();\n- Iterator<Object> value_it = values.iterator();\n- String key_var;\n- Object value_var;\n- while (key_it.hasNext() && value_it.hasNext()) {\n- key_var = key_it.next();\n- value_var = value_it.next();\n- result.put(key_var, value_var);\n- }\n- }\n- return result;\n- }\n-\n- public void query(String key, Function<String, ?> deserializer, Consumer<Object> callback) {\n- queue.add(Tuple.of(key, deserializer, callback));\n- }\n-\n- public <T> IBulkQuery.Value<T> get(String hash, Function<String, T> deserializer) {\n- final Value<T> result = new Value<>();\n- query(hash, deserializer, value -> result.success((T) value));\n- return result;\n- }\n-\n- public <T> IBulkQuery.Value<T> constant(T value) {\n- return new Value<T>(value);\n- }\n-\n- public void process() {\n- if (processing) {\n- throw new RuntimeException(\"Already processing\");\n- }\n- processing = true;\n- try {\n- while (!queue.isEmpty()) {\n- final List<Tuple3<String, Function<String, ?>, Consumer<Object>>> currentRequests = queue;\n- queue = new ArrayList<>();\n-\n- Map<String, Function<String, ?>> deserializers = new HashMap<>();\n- for (Tuple3<String, Function<String, ?>, Consumer<Object>> request : currentRequests) {\n- deserializers.put(request._1(), request._2());\n- }\n-\n- final Map<String, Object> entries = executeBulkQuery(\n- currentRequests.stream()\n- .map(Tuple3::_1)\n- .distinct()\n- .collect(Collectors.toList()),\n- deserializers);\n- for (Tuple3<String, Function<String, ?>, Consumer<Object>> request : currentRequests) {\n- request._3().accept(entries.get(request._1()));\n- }\n- }\n- } finally {\n- processing = false;\n- }\n- }\n-\n- public <I, O> IBulkQuery.Value<List<O>> map(Iterable<I> input_, Function<I, IBulkQuery.Value<O>> f) {\n- List<I> input = StreamSupport.stream(input_.spliterator(), false).collect(Collectors.toList());\n- if (input.isEmpty()) {\n- return constant(Collections.<O>emptyList());\n- }\n- final Object[] output = new Object[input.size()];\n- final boolean[] done = new boolean[input.size()];\n- final MutableInt remaining = new MutableInt(input.size());\n- final Value<List<O>> result = new Value<>();\n- for (int i_ = 0; i_ < input.size(); i_++) {\n- final int i = i_;\n- f.apply(input.get(i)).onSuccess(new Consumer<O>() {\n- public void accept(O value) {\n- if (done[i]) {\n- return;\n- }\n- output[i] = value;\n- done[i] = true;\n- remaining.decrement();\n- if (remaining.intValue() == 0) {\n- result.success(Arrays.stream(output).map(e -> (O) e).collect(Collectors.toList()));\n- }\n- }\n- });\n- }\n- return result;\n- }\n-\n- public class Value<T> implements IBulkQuery.Value<T> {\n- private List<Consumer<T>> handlers = new ArrayList<>();\n- private T value;\n- private boolean done = false;\n-\n- public Value() {\n- }\n-\n- public Value(T value) {\n- this.value = value;\n- done = true;\n- }\n-\n- public synchronized void success(T value) {\n- if (done) {\n- throw new IllegalStateException(\"Value is already set\");\n- } else {\n- this.value = value;\n- this.done = true;\n- for (Consumer<T> handler : handlers) {\n- handler.accept(value);\n- }\n- handlers = null;\n- }\n- }\n-\n- public synchronized void onSuccess(Consumer<T> handler) {\n- if (done) {\n- handler.accept(value);\n- } else {\n- handlers.add(handler);\n- }\n- }\n-\n- public T execute() {\n- process();\n- if (!(done)) {\n- throw new RuntimeException(\"No value received\");\n- }\n- return value;\n- }\n-\n- public <R> IBulkQuery.Value<R> map(final Function<T, R> handler) {\n- final Value<R> result = new Value<>();\n- onSuccess(v -> result.success(handler.apply(v)));\n- return result;\n- }\n-\n- public <R> IBulkQuery.Value<R> mapBulk(final Function<T, IBulkQuery.Value<R>> handler) {\n- final Value<R> result = new Value<>();\n- onSuccess(v -> handler.apply(v).onSuccess(result::success));\n- return result;\n- }\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.kt", "diff": "+package org.modelix.model.lazy\n+\n+import io.vavr.Tuple\n+import io.vavr.Tuple3\n+import org.apache.commons.lang3.mutable.MutableInt\n+import java.util.*\n+import java.util.function.Consumer\n+import java.util.function.Function\n+import java.util.stream.Collectors\n+import java.util.stream.StreamSupport\n+\n+/**\n+ * Not thread safe\n+ */\n+class BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\n+ private var queue: MutableList<Tuple3<String, Function<String, *>, Consumer<Any?>>> = ArrayList()\n+ private var processing = false\n+ protected fun executeBulkQuery(keys: Iterable<String>, deserializers: Map<String, Function<String, *>>): Map<String, Any> {\n+ val values = store.getAll(keys) { key: String?, serialized: String? -> deserializers[key]!!.apply(serialized!!) }\n+ val result: MutableMap<String, Any> = HashMap()\n+ run {\n+ val key_it = keys.iterator()\n+ val value_it: Iterator<Any> = values.iterator()\n+ var key_var: String\n+ var value_var: Any\n+ while (key_it.hasNext() && value_it.hasNext()) {\n+ key_var = key_it.next()\n+ value_var = value_it.next()\n+ result[key_var] = value_var\n+ }\n+ }\n+ return result\n+ }\n+\n+ fun query(key: String, deserializer: Function<String, *>, callback: Consumer<Any?>) {\n+ queue.add(Tuple.of<String, Function<String, *>, Consumer<Any?>>(key, deserializer, callback))\n+ }\n+\n+ override fun <T> get(hash: String, deserializer: Function<String, T>): IBulkQuery.Value<T> {\n+ val result = Value<T>()\n+ query(hash, deserializer, Consumer { value: Any? -> result.success(value as T) })\n+ return result\n+ }\n+\n+ override fun <T> constant(value: T): IBulkQuery.Value<T> {\n+ return Value(value)\n+ }\n+\n+ fun process() {\n+ if (processing) {\n+ throw RuntimeException(\"Already processing\")\n+ }\n+ processing = true\n+ try {\n+ while (!queue.isEmpty()) {\n+ val currentRequests: List<Tuple3<String, Function<String, *>, Consumer<Any?>>> = queue\n+ queue = ArrayList()\n+ val deserializers: MutableMap<String, Function<String, *>> = HashMap()\n+ for (request in currentRequests) {\n+ deserializers[request._1()] = request._2()\n+ }\n+ val entries = executeBulkQuery(\n+ currentRequests.stream()\n+ .map { obj: Tuple3<String, Function<String, *>, Consumer<Any?>> -> obj._1() }\n+ .distinct()\n+ .collect(Collectors.toList()),\n+ deserializers)\n+ for (request in currentRequests) {\n+ request._3().accept(entries[request._1()])\n+ }\n+ }\n+ } finally {\n+ processing = false\n+ }\n+ }\n+\n+ override fun <I, O> map(input_: Iterable<I>, f: Function<I, IBulkQuery.Value<O>>): IBulkQuery.Value<List<O>> {\n+ val input = StreamSupport.stream(input_.spliterator(), false).collect(Collectors.toList())\n+ if (input.isEmpty()) {\n+ return constant(emptyList())\n+ }\n+ val output = arrayOfNulls<Any>(input.size)\n+ val done = BooleanArray(input.size)\n+ val remaining = MutableInt(input.size)\n+ val result = Value<List<O>>()\n+ for (i_ in input.indices) {\n+ f.apply(input[i_]).onSuccess(Consumer { value ->\n+ if (done[i_]) {\n+ return@Consumer\n+ }\n+ output[i_] = value\n+ done[i_] = true\n+ remaining.decrement()\n+ if (remaining.toInt() == 0) {\n+ result.success(Arrays.stream(output).map { e: Any? -> e as O }.collect(Collectors.toList()))\n+ }\n+ })\n+ }\n+ return result\n+ }\n+\n+ inner class Value<T> : IBulkQuery.Value<T> {\n+ private var handlers: MutableList<Consumer<T?>>? = ArrayList()\n+ private var value: T? = null\n+ private var done = false\n+\n+ constructor() {}\n+ constructor(value: T) {\n+ this.value = value\n+ done = true\n+ }\n+\n+ @Synchronized\n+ fun success(value: T) {\n+ check(!done) { \"Value is already set\" }\n+ this.value = value\n+ done = true\n+ for (handler in handlers!!) {\n+ handler.accept(value)\n+ }\n+ handlers = null\n+ }\n+\n+ @Synchronized\n+ override fun onSuccess(handler: Consumer<T?>) {\n+ if (done) {\n+ handler.accept(value)\n+ } else {\n+ handlers!!.add(handler)\n+ }\n+ }\n+\n+ override fun execute(): T {\n+ process()\n+ if (!done) {\n+ throw RuntimeException(\"No value received\")\n+ }\n+ return value!!\n+ }\n+\n+ override fun <R> map(handler: Function<T, R>): IBulkQuery.Value<R> {\n+ val result = Value<R>()\n+ onSuccess { v: T? -> result.success(handler.apply(v!!)) }\n+ return result\n+ }\n+\n+ override fun <R> mapBulk(handler: Function<T, IBulkQuery.Value<R>>): IBulkQuery.Value<R> {\n+ val result = Value<R>()\n+ onSuccess { v: T? -> handler.apply(v!!).onSuccess { value: R -> result.success(value) } }\n+ return result\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate BulkQuery
426,504
01.08.2020 14:29:48
-7,200
1cdacfea99455c0b73d33b05ca0dbdb0a007ff30
translate CLElementRef
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLElementRef.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-public class CLElementRef {\n- private long id;\n-\n- public CLElementRef(long id) {\n- this.id = id;\n- }\n-\n- public long getId() {\n- return id;\n- }\n-\n- @Override\n- public boolean equals(Object o) {\n- if (this == o) {\n- return true;\n- }\n- if (o == null || this.getClass() != o.getClass()) {\n- return false;\n- }\n-\n- CLElementRef that = (CLElementRef) o;\n- if (id != that.id) {\n- return false;\n- }\n-\n- return true;\n- }\n-\n- @Override\n- public int hashCode() {\n- int result = 0;\n- result = 31 * result + (int) (id ^ (id >> 32));\n- return result;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLElementRef.kt", "diff": "+package org.modelix.model.lazy\n+\n+class CLElementRef(val id: Long) {\n+\n+ override fun equals(o: Any?): Boolean {\n+ if (this === o) {\n+ return true\n+ }\n+ if (o == null || this.javaClass != o.javaClass) {\n+ return false\n+ }\n+ val that = o as CLElementRef\n+ return if (id != that.id) {\n+ false\n+ } else true\n+ }\n+\n+ override fun hashCode(): Int {\n+ var result = 0\n+ result = 31 * result + (id xor (id shr 32)).toInt()\n+ return result\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CLElementRef
426,504
01.08.2020 14:31:02
-7,200
ea881290f4ecbb0f855e53d91a97c15d7b9f49ec
translate CLHamtInternal
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLHamtInternal.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.modelix.model.util.pmap.COWArrays;\n-import org.modelix.model.util.pmap.LongKeyPMap;\n-import org.modelix.model.persistent.CPHamtInternal;\n-import org.modelix.model.persistent.CPHamtNode;\n-import org.modelix.model.persistent.HashUtil;\n-\n-import java.util.Objects;\n-import java.util.function.BiPredicate;\n-\n-public class CLHamtInternal extends CLHamtNode<CPHamtInternal> {\n-\n- private final CPHamtInternal data;\n-\n- public CLHamtInternal(IDeserializingKeyValueStore store) {\n- this(0, new String[0], store);\n- }\n-\n- public CLHamtInternal(CPHamtInternal data, IDeserializingKeyValueStore store) {\n- super(store);\n- this.data = data;\n- }\n-\n- private CLHamtInternal(int bitmap, String[] childHashes, IDeserializingKeyValueStore store) {\n- super(store);\n- this.data = new CPHamtInternal(bitmap, childHashes);\n- String serialized = this.data.serialize();\n- store.put(HashUtil.sha256(serialized), data, serialized);\n- }\n-\n- public CLHamtNode put(long key, String value, int shift) {\n- int childIndex = (int) ((key >>> shift) & LEVEL_MASK);\n- CLHamtNode child = getChild(childIndex, new NonBulkQuery(store)).execute();\n- if (child == null) {\n- return setChild(childIndex, CLHamtLeaf.create(key, value, store));\n- } else {\n- return setChild(childIndex, child.put(key, value, shift + BITS_PER_LEVEL));\n- }\n- }\n-\n- public CLHamtNode remove(long key, int shift) {\n- int childIndex = (int) ((key >>> shift) & LEVEL_MASK);\n- CLHamtNode child = getChild(childIndex, new NonBulkQuery(store)).execute();\n- if (child == null) {\n- return this;\n- } else {\n- return setChild(childIndex, child.remove(key, shift + BITS_PER_LEVEL));\n- }\n- }\n-\n- @Override\n- public IBulkQuery.Value<String> get(final long key, final int shift, final IBulkQuery bulkQuery) {\n- int childIndex = (int) ((key >>> shift) & LEVEL_MASK);\n- return getChild(childIndex, bulkQuery).mapBulk(child -> {\n- if (child == null) {\n- return bulkQuery.<String>constant(null);\n- }\n- return child.get(key, shift + BITS_PER_LEVEL, bulkQuery);\n- });\n- }\n-\n- protected IBulkQuery.Value<CLHamtNode> getChild(int logicalIndex, IBulkQuery bulkQuery) {\n- if (CLHamtNode.isBitNotSet(data.bitmap, logicalIndex)) {\n- return bulkQuery.<CLHamtNode>constant(null);\n- }\n- int physicalIndex = CLHamtNode.logicalToPhysicalIndex(data.bitmap, logicalIndex);\n- return getChild(data.children[physicalIndex], bulkQuery);\n- }\n-\n- protected IBulkQuery.Value<CLHamtNode> getChild(String childHash, IBulkQuery bulkQuery) {\n- return bulkQuery.get(childHash, CPHamtNode.DESERIALIZER).map(childData -> CLHamtNode.create(childData, store));\n- }\n-\n- protected CLHamtNode getChild(int logicalIndex) {\n- return getChild(logicalIndex, new NonBulkQuery(store)).execute();\n- }\n-\n- protected CLHamtNode getChild(String childHash) {\n- return getChild(childHash, new NonBulkQuery(store)).execute();\n- }\n-\n- public CLHamtNode setChild(int logicalIndex, CLHamtNode child) {\n- if (child == null) {\n- return deleteChild(logicalIndex);\n- }\n-\n- String childHash = HashUtil.sha256(child.getData().serialize());\n- int physicalIndex = CLHamtNode.logicalToPhysicalIndex(data.bitmap, logicalIndex);\n- if (LongKeyPMap.isBitNotSet(data.bitmap, logicalIndex)) {\n- return new CLHamtInternal(data.bitmap | (1 << logicalIndex), COWArrays.insert(data.children, physicalIndex, childHash), store);\n- } else {\n- return new CLHamtInternal(data.bitmap, COWArrays.set(data.children, physicalIndex, childHash), store);\n- }\n- }\n-\n- public CLHamtNode deleteChild(int logicalIndex) {\n- if (CLHamtNode.isBitNotSet(data.bitmap, logicalIndex)) {\n- return this;\n- }\n- int physicalIndex = LongKeyPMap.logicalToPhysicalIndex(data.bitmap, logicalIndex);\n- int newBitmap = data.bitmap & (~(1 << logicalIndex));\n- if (newBitmap == 0) {\n- return null;\n- }\n-\n- String[] newChildren = COWArrays.removeAt(data.children, physicalIndex);\n- if (newChildren.length == 1) {\n- CLHamtNode child0 = getChild(newChildren[0], new NonBulkQuery(store)).execute();\n- if (child0 instanceof CLHamtLeaf) {\n- return child0;\n- }\n- }\n- return new CLHamtInternal(newBitmap, newChildren, store);\n- }\n-\n- @Override\n- public boolean visitEntries(BiPredicate<Long, String> visitor) {\n- for (String childHash : data.children) {\n- CLHamtNode child = getChild(childHash);\n- boolean continueVisit = child.visitEntries(visitor);\n- if (!(continueVisit)) {\n- return false;\n- }\n- }\n- return true;\n- }\n-\n- @Override\n- public void visitChanges(CLHamtNode oldNode, final CLHamtNode.IChangeVisitor visitor) {\n- if (oldNode == this) {\n- return;\n- }\n-\n- if (oldNode instanceof CLHamtInternal) {\n- CLHamtInternal oldInternalNode = ((CLHamtInternal) oldNode);\n- if (data.bitmap == oldInternalNode.data.bitmap) {\n- for (int i = 0; i < data.children.length; i++) {\n- getChild(data.children[i]).visitChanges(oldInternalNode.getChild(oldInternalNode.data.children[i]), visitor);\n- }\n- } else {\n- for (int logicalIndex = 0; logicalIndex < CLHamtNode.ENTRIES_PER_LEVEL; logicalIndex++) {\n- CLHamtNode child = getChild(logicalIndex);\n- CLHamtNode oldChild = oldInternalNode.getChild(logicalIndex);\n-\n- if (child == null) {\n- if (oldChild == null) {\n- // no change\n- } else {\n- oldChild.visitEntries(new BiPredicate<Long, String>() {\n- public boolean test(Long key, String value) {\n- visitor.entryRemoved(key, value);\n- return true;\n- }\n- });\n- }\n- } else {\n- if (oldChild == null) {\n- child.visitEntries(new BiPredicate<Long, String>() {\n- public boolean test(Long key, String value) {\n- visitor.entryAdded(key, value);\n- return true;\n- }\n- });\n- } else {\n- child.visitChanges(oldChild, visitor);\n- }\n- }\n- }\n- }\n- } else if (oldNode instanceof CLHamtLeaf) {\n- final CLHamtLeaf oldLeafNode = ((CLHamtLeaf) oldNode);\n- visitEntries(new BiPredicate<Long, String>() {\n- public boolean test(Long k, String v) {\n- if (k == oldLeafNode.getKey()) {\n- String oldValue = oldLeafNode.getValue();\n- if (!(Objects.equals(v, oldValue))) {\n- visitor.entryChanged(k, oldValue, v);\n- }\n- } else {\n- visitor.entryAdded(k, v);\n- }\n- return true;\n- }\n- });\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + oldNode.getClass().getName());\n- }\n- }\n-\n- @Override\n- public CPHamtNode getData() {\n- return data;\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.lazy.CLHamtLeaf\n+import org.modelix.model.persistent.CPHamtInternal\n+import org.modelix.model.persistent.CPHamtNode\n+import org.modelix.model.persistent.HashUtil\n+import org.modelix.model.util.pmap.COWArrays\n+import org.modelix.model.util.pmap.LongKeyPMap\n+import java.util.function.BiPredicate\n+\n+class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n+ private val data: CPHamtInternal\n+\n+ constructor(store: IDeserializingKeyValueStore) : this(0, arrayOfNulls<String>(0), store) {}\n+ constructor(data: CPHamtInternal, store: IDeserializingKeyValueStore?) : super(store) {\n+ this.data = data\n+ }\n+\n+ private constructor(bitmap: Int, childHashes: Array<String?>, store: IDeserializingKeyValueStore) : super(store) {\n+ data = CPHamtInternal(bitmap, childHashes)\n+ val serialized = data.serialize()\n+ store.put(HashUtil.sha256(serialized), data, serialized)\n+ }\n+\n+ override fun put(key: Long, value: String, shift: Int): CLHamtNode<*>? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex, NonBulkQuery(store)).execute()\n+ return if (child == null) {\n+ setChild(childIndex, CLHamtLeaf.create(key, value, store))\n+ } else {\n+ setChild(childIndex, child.put(key, value, shift + BITS_PER_LEVEL))\n+ }\n+ }\n+\n+ override fun remove(key: Long, shift: Int): CLHamtNode<*>? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex, NonBulkQuery(store)).execute()\n+ return if (child == null) {\n+ this\n+ } else {\n+ setChild(childIndex, child.remove(key, shift + BITS_PER_LEVEL))\n+ }\n+ }\n+\n+ override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<String> {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ return getChild(childIndex, bulkQuery).mapBulk<String> { child: CLHamtNode<*>? ->\n+ if (child == null) {\n+ return@mapBulk bulkQuery.constant<String?>(null)\n+ }\n+ child[key, shift + BITS_PER_LEVEL, bulkQuery]\n+ }\n+ }\n+\n+ protected fun getChild(logicalIndex: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n+ if (isBitNotSet(data.bitmap, logicalIndex)) {\n+ return bulkQuery.constant(null)\n+ }\n+ val physicalIndex = logicalToPhysicalIndex(data.bitmap, logicalIndex)\n+ return getChild(data.children[physicalIndex], bulkQuery)\n+ }\n+\n+ protected fun getChild(childHash: String?, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n+ return bulkQuery.get(childHash, CPHamtNode.DESERIALIZER).map { childData: CPHamtNode? -> create(childData, store) }\n+ }\n+\n+ protected fun getChild(logicalIndex: Int): CLHamtNode<*>? {\n+ return getChild(logicalIndex, NonBulkQuery(store)).execute()\n+ }\n+\n+ protected fun getChild(childHash: String?): CLHamtNode<*>? {\n+ return getChild(childHash, NonBulkQuery(store)).execute()\n+ }\n+\n+ fun setChild(logicalIndex: Int, child: CLHamtNode<*>?): CLHamtNode<*>? {\n+ if (child == null) {\n+ return deleteChild(logicalIndex)\n+ }\n+ val childHash = HashUtil.sha256(child.data.serialize())\n+ val physicalIndex = logicalToPhysicalIndex(data.bitmap, logicalIndex)\n+ return if (LongKeyPMap.isBitNotSet(data.bitmap, logicalIndex)) {\n+ CLHamtInternal(data.bitmap or (1 shl logicalIndex), COWArrays.insert(data.children, physicalIndex, childHash), store)\n+ } else {\n+ CLHamtInternal(data.bitmap, COWArrays.set(data.children, physicalIndex, childHash), store)\n+ }\n+ }\n+\n+ fun deleteChild(logicalIndex: Int): CLHamtNode<*>? {\n+ if (isBitNotSet(data.bitmap, logicalIndex)) {\n+ return this\n+ }\n+ val physicalIndex = LongKeyPMap.logicalToPhysicalIndex(data.bitmap, logicalIndex)\n+ val newBitmap = data.bitmap and (1 shl logicalIndex).inv()\n+ if (newBitmap == 0) {\n+ return null\n+ }\n+ val newChildren = COWArrays.removeAt(data.children, physicalIndex)\n+ if (newChildren.size == 1) {\n+ val child0 = getChild(newChildren[0], NonBulkQuery(store)).execute()\n+ if (child0 is CLHamtLeaf) {\n+ return child0\n+ }\n+ }\n+ return CLHamtInternal(newBitmap, newChildren, store)\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, String>): Boolean {\n+ for (childHash in data.children) {\n+ val child = getChild(childHash)\n+ val continueVisit = child!!.visitEntries(visitor)\n+ if (!continueVisit) {\n+ return false\n+ }\n+ }\n+ return true\n+ }\n+\n+ override fun visitChanges(oldNode: CLHamtNode<*>, visitor: IChangeVisitor) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ if (oldNode is CLHamtInternal) {\n+ val oldInternalNode = oldNode\n+ if (data.bitmap == oldInternalNode.data.bitmap) {\n+ for (i in data.children.indices) {\n+ getChild(data.children[i])!!.visitChanges(oldInternalNode.getChild(oldInternalNode.data.children[i]), visitor)\n+ }\n+ } else {\n+ for (logicalIndex in 0 until ENTRIES_PER_LEVEL) {\n+ val child = getChild(logicalIndex)\n+ val oldChild = oldInternalNode.getChild(logicalIndex)\n+ if (child == null) {\n+ if (oldChild == null) {\n+ // no change\n+ } else {\n+ oldChild.visitEntries(BiPredicate { key, value ->\n+ visitor.entryRemoved(key!!, value)\n+ true\n+ })\n+ }\n+ } else {\n+ if (oldChild == null) {\n+ child.visitEntries(BiPredicate { key, value ->\n+ visitor.entryAdded(key!!, value)\n+ true\n+ })\n+ } else {\n+ child.visitChanges(oldChild, visitor)\n+ }\n+ }\n+ }\n+ }\n+ } else if (oldNode is CLHamtLeaf) {\n+ val oldLeafNode = oldNode\n+ visitEntries(BiPredicate<Long, String> { k, v ->\n+ if (k == oldLeafNode.key) {\n+ val oldValue = oldLeafNode.value\n+ if (v != oldValue) {\n+ visitor.entryChanged(k, oldValue, v)\n+ }\n+ } else {\n+ visitor.entryAdded(k, v)\n+ }\n+ true\n+ })\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + oldNode.javaClass.name)\n+ }\n+ }\n+\n+ override fun getData(): CPHamtNode {\n+ return data\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CLHamtInternal
426,504
01.08.2020 14:35:40
-7,200
e4bb46644c957bfab5654b6e765a131740db6d10
translate AbstractOperation
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/AbstractOperation.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-public abstract class AbstractOperation implements IOperation {\n- public AbstractOperation() {\n- }\n-\n- public abstract class Applied {\n- @Override\n- public String toString() {\n- return \"applied:\" + AbstractOperation.this.toString();\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/AbstractOperation.kt", "diff": "+package org.modelix.model.operations\n+\n+abstract class AbstractOperation : IOperation {\n+ abstract inner class Applied {\n+ override fun toString(): String {\n+ return \"applied:\" + [email protected]()\n+ }\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate AbstractOperation
426,504
01.08.2020 14:38:09
-7,200
4e1edaa80e292c6dd8166396d80cebe2cdc2f5cd
translate AddNewChildOp
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/AddNewChildOp.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IConcept;\n-import org.modelix.model.api.IWriteTransaction;\n-import java.util.Objects;\n-import java.text.MessageFormat;\n-\n-public class AddNewChildOp extends AbstractOperation implements IModifiesChildrenOp {\n-\n- public final long parentId;\n- public final String role;\n- public final int index;\n- public final long childId;\n- public final IConcept concept;\n-\n- public AddNewChildOp(long parentId, String role, int index, long childId, IConcept concept) {\n- this.childId = childId;\n- this.concept = concept;\n- this.index = index;\n- this.parentId = parentId;\n- this.role = role;\n- }\n-\n- public AddNewChildOp withIndex(int newIndex) {\n- return (newIndex == index ? this : new AddNewChildOp(parentId, role, newIndex, childId, concept));\n- }\n-\n- @Override\n- public IAppliedOperation apply(IWriteTransaction transaction) {\n- transaction.addNewChild(parentId, role, index, childId, concept);\n- return new Applied();\n- }\n-\n- @Override\n- public IOperation transform(IOperation previous) {\n- if (previous instanceof AddNewChildOp) {\n- AddNewChildOp o = ((AddNewChildOp) previous);\n- if (Objects.equals(o.parentId, parentId) && Objects.equals(o.role, role)) {\n- if (o.index <= index) {\n- return new AddNewChildOp(parentId, role, index + 1, childId, concept);\n- } else {\n- return this;\n- }\n- } else {\n- return this;\n- }\n- } else if (previous instanceof DeleteNodeOp) {\n- DeleteNodeOp o = ((DeleteNodeOp) previous);\n- return withIndex(o.adjustIndex(parentId, role, index));\n- } else if (previous instanceof MoveNodeOp) {\n- MoveNodeOp o = ((MoveNodeOp) previous);\n- return withIndex(o.adjustIndex(parentId, role, index));\n- } else if (previous instanceof SetPropertyOp) {\n- return this;\n- } else if (previous instanceof SetReferenceOp) {\n- return this;\n- } else if (previous instanceof NoOp) {\n- return this;\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + previous.getClass().getName());\n- }\n- }\n-\n- @Override\n- public int adjustIndex(long otherParentId, String otherRole, int otherIndex) {\n- int adjustedIndex = otherIndex;\n- if (Objects.equals(otherParentId, parentId) && Objects.equals(otherRole, role) && index <= otherIndex) {\n- adjustedIndex++;\n- }\n- return adjustedIndex;\n- }\n-\n- @Override\n- public String toString() {\n- return MessageFormat.format(\"AddNewChildOp {0}, {1}.{2}[{3}], {4}\", Long.toHexString(childId), Long.toHexString(parentId), role, index, concept);\n- }\n-\n- public class Applied extends AbstractOperation.Applied implements IAppliedOperation {\n-\n- public Applied() {\n- }\n-\n- @Override\n- public IOperation getOriginalOp() {\n- return AddNewChildOp.this;\n- }\n-\n- @Override\n- public IOperation invert() {\n- return new DeleteNodeOp(parentId, role, index, childId);\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/AddNewChildOp.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.modelix.model.api.IConcept\n+import org.modelix.model.api.IWriteTransaction\n+import java.text.MessageFormat\n+\n+class AddNewChildOp(val parentId: Long, val role: String, val index: Int, val childId: Long, val concept: IConcept) : AbstractOperation(), IModifiesChildrenOp {\n+ fun withIndex(newIndex: Int): AddNewChildOp {\n+ return if (newIndex == index) this else AddNewChildOp(parentId, role, newIndex, childId, concept)\n+ }\n+\n+ override fun apply(transaction: IWriteTransaction?): IAppliedOperation? {\n+ transaction!!.addNewChild(parentId, role, index, childId, concept)\n+ return Applied()\n+ }\n+\n+ override fun transform(previous: IOperation?): IOperation? {\n+ return if (previous is AddNewChildOp) {\n+ val o = previous\n+ if (o.parentId == parentId && o.role == role) {\n+ if (o.index <= index) {\n+ AddNewChildOp(parentId, role, index + 1, childId, concept)\n+ } else {\n+ this\n+ }\n+ } else {\n+ this\n+ }\n+ } else if (previous is DeleteNodeOp) {\n+ withIndex(previous.adjustIndex(parentId, role, index))\n+ } else if (previous is MoveNodeOp) {\n+ withIndex(previous.adjustIndex(parentId, role, index))\n+ } else if (previous is SetPropertyOp) {\n+ this\n+ } else if (previous is SetReferenceOp) {\n+ this\n+ } else if (previous is NoOp) {\n+ this\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + previous!!.javaClass.getName())\n+ }\n+ }\n+\n+ override fun adjustIndex(otherParentId: Long, otherRole: String?, otherIndex: Int): Int {\n+ var adjustedIndex = otherIndex\n+ if (otherParentId == parentId && otherRole == role && index <= otherIndex) {\n+ adjustedIndex++\n+ }\n+ return adjustedIndex\n+ }\n+\n+ override fun toString(): String {\n+ return MessageFormat.format(\"AddNewChildOp {0}, {1}.{2}[{3}], {4}\", java.lang.Long.toHexString(childId), java.lang.Long.toHexString(parentId), role, index, concept)\n+ }\n+\n+ inner class Applied : AbstractOperation.Applied(), IAppliedOperation {\n+ override val originalOp: IOperation\n+ get() = this@AddNewChildOp\n+\n+ override fun invert(): IOperation? {\n+ return DeleteNodeOp(parentId, role, index, childId)\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/operations/DeleteNodeOp.java", "new_path": "model-client/src/main/java/org/modelix/model/operations/DeleteNodeOp.java", "diff": "@@ -50,8 +50,8 @@ public class DeleteNodeOp extends AbstractOperation implements IModifiesChildren\n}\n} else if (previous instanceof AddNewChildOp) {\nAddNewChildOp o = ((AddNewChildOp) previous);\n- if (Objects.equals(parentId, o.parentId) && Objects.equals(role, o.role)) {\n- if (o.index <= index) {\n+ if (Objects.equals(parentId, o.getParentId()) && Objects.equals(role, o.getRole())) {\n+ if (o.getIndex() <= index) {\nreturn new DeleteNodeOp(parentId, role, index + 1, childId);\n} else {\nreturn this;\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "new_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "diff": "@@ -22,7 +22,7 @@ public class OperationSerializer {\nINSTANCE.registerSerializer(AddNewChildOp.class, new Serializer<AddNewChildOp>() {\n@Override\npublic String serialize(AddNewChildOp op) {\n- return SerializationUtil.longToHex(op.parentId) + SEPARATOR + SerializationUtil.escape(op.role) + SEPARATOR + op.index + SEPARATOR + SerializationUtil.longToHex(op.childId) + SEPARATOR + serializeConcept(op.concept);\n+ return SerializationUtil.longToHex(op.getParentId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + op.getIndex() + SEPARATOR + SerializationUtil.longToHex(op.getChildId()) + SEPARATOR + serializeConcept(op.getConcept());\n}\n@Override\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate AddNewChildOp
426,504
01.08.2020 14:40:30
-7,200
66a039499fb3501d66bc9f1acba1ec57c1b4de69
translate DeleteNodeOp
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/DeleteNodeOp.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IWriteTransaction;\n-import org.modelix.model.api.IConcept;\n-import java.util.Objects;\n-import java.text.MessageFormat;\n-\n-public class DeleteNodeOp extends AbstractOperation implements IModifiesChildrenOp {\n-\n- public final long parentId;\n- public final String role;\n- public final int index;\n- public final long childId;\n-\n- public DeleteNodeOp(long parentId, String role, int index, long childId) {\n- this.childId = childId;\n- this.index = index;\n- this.parentId = parentId;\n- this.role = role;\n- }\n-\n- public DeleteNodeOp withIndex(int newIndex) {\n- return (newIndex == index ? this : new DeleteNodeOp(parentId, role, newIndex, childId));\n- }\n-\n- @Override\n- public IAppliedOperation apply(IWriteTransaction transaction) {\n- IConcept concept = transaction.getConcept(childId);\n- transaction.deleteNode(childId);\n- return new Applied(concept);\n- }\n-\n- @Override\n- public IOperation transform(IOperation previous) {\n- if (previous instanceof DeleteNodeOp) {\n- DeleteNodeOp o = ((DeleteNodeOp) previous);\n- if (Objects.equals(parentId, o.parentId) && Objects.equals(role, o.role)) {\n- if (o.index < index) {\n- return new DeleteNodeOp(parentId, role, index - 1, childId);\n- } else if (Objects.equals(o.index, index)) {\n- if (!(Objects.equals(o.childId, childId))) {\n- throw new RuntimeException(\"Both operations delete \" + parentId + \".\" + role + \"[\" + index + \"] but with different expected IDs \" + childId + \" and \" + o.childId);\n- }\n- return new NoOp();\n- } else {\n- return this;\n- }\n- } else {\n- return this;\n- }\n- } else if (previous instanceof AddNewChildOp) {\n- AddNewChildOp o = ((AddNewChildOp) previous);\n- if (Objects.equals(parentId, o.getParentId()) && Objects.equals(role, o.getRole())) {\n- if (o.getIndex() <= index) {\n- return new DeleteNodeOp(parentId, role, index + 1, childId);\n- } else {\n- return this;\n- }\n- } else {\n- return this;\n- }\n- } else if (previous instanceof MoveNodeOp) {\n- MoveNodeOp o = ((MoveNodeOp) previous);\n- if (Objects.equals(o.childId, childId)) {\n- if (!(Objects.equals(o.sourceParentId, parentId)) || !(Objects.equals(o.sourceRole, role)) || !(Objects.equals(o.sourceIndex, index))) {\n- throw new RuntimeException(\"node \" + childId + \" expected to be at \" + parentId + \".\" + role + \"[\" + index + \"]\" + \" but was \" + o.sourceParentId + \".\" + o.sourceRole + \"[\" + o.sourceIndex + \"]\");\n- }\n- return new DeleteNodeOp(o.targetParentId, o.targetRole, o.targetIndex, childId);\n- } else if (Objects.equals(parentId, o.targetParentId) && Objects.equals(role, o.targetRole)) {\n- return withIndex(o.adjustIndex(parentId, role, index));\n- } else if (Objects.equals(parentId, o.sourceParentId) && Objects.equals(role, o.sourceRole)) {\n- if (o.sourceIndex == index) {\n- throw new RuntimeException(\"Node at \" + parentId + \".\" + role + \"[\" + index + \"] is expected to be \" + childId + \", but was \" + o.childId);\n- } else {\n- return withIndex(o.adjustIndex(parentId, role, index));\n- }\n- } else {\n- return this;\n- }\n- } else if (previous instanceof SetPropertyOp) {\n- return this;\n- } else if (previous instanceof SetReferenceOp) {\n- return this;\n- } else if (previous instanceof NoOp) {\n- return this;\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + previous.getClass().getName());\n- }\n- }\n-\n- @Override\n- public int adjustIndex(long otherParentId, String otherRole, int otherIndex) {\n- int adjustedIndex = otherIndex;\n- if (Objects.equals(otherParentId, parentId) && Objects.equals(otherRole, role) && index < otherIndex) {\n- adjustedIndex--;\n- }\n- return adjustedIndex;\n- }\n-\n- @Override\n- public String toString() {\n- return MessageFormat.format(\"DeleteNodeOp {0}, {1}.{2}[{3}]\", Long.toHexString(childId), Long.toHexString(parentId), role, index);\n- }\n-\n- public class Applied extends AbstractOperation.Applied implements IAppliedOperation {\n- private IConcept concept;\n-\n- public Applied(IConcept concept) {\n- this.concept = concept;\n- }\n-\n- @Override\n- public IOperation getOriginalOp() {\n- return DeleteNodeOp.this;\n- }\n-\n- @Override\n- public IOperation invert() {\n- return new AddNewChildOp(parentId, role, index, childId, concept);\n- }\n-\n- @Override\n- public String toString() {\n- return super.toString() + \", concept: \" + concept;\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.modelix.model.api.IConcept\n+import org.modelix.model.api.IWriteTransaction\n+import java.text.MessageFormat\n+\n+class DeleteNodeOp(val parentId: Long, val role: String, val index: Int, val childId: Long) : AbstractOperation(), IModifiesChildrenOp {\n+ fun withIndex(newIndex: Int): DeleteNodeOp {\n+ return if (newIndex == index) this else DeleteNodeOp(parentId, role, newIndex, childId)\n+ }\n+\n+ override fun apply(transaction: IWriteTransaction?): IAppliedOperation? {\n+ val concept = transaction!!.getConcept(childId)\n+ transaction.deleteNode(childId)\n+ return Applied(concept!!)\n+ }\n+\n+ override fun transform(previous: IOperation?): IOperation? {\n+ return if (previous is DeleteNodeOp) {\n+ val o = previous\n+ if (parentId == o.parentId && role == o.role) {\n+ if (o.index < index) {\n+ DeleteNodeOp(parentId, role, index - 1, childId)\n+ } else if (o.index == index) {\n+ if (o.childId != childId) {\n+ throw RuntimeException(\"Both operations delete \" + parentId + \".\" + role + \"[\" + index + \"] but with different expected IDs \" + childId + \" and \" + o.childId)\n+ }\n+ NoOp()\n+ } else {\n+ this\n+ }\n+ } else {\n+ this\n+ }\n+ } else if (previous is AddNewChildOp) {\n+ val o = previous\n+ if (parentId == o.parentId && role == o.role) {\n+ if (o.index <= index) {\n+ DeleteNodeOp(parentId, role, index + 1, childId)\n+ } else {\n+ this\n+ }\n+ } else {\n+ this\n+ }\n+ } else if (previous is MoveNodeOp) {\n+ val o = previous\n+ if (o.childId == childId) {\n+ if (o.sourceParentId != parentId || o.sourceRole != role || o.sourceIndex != index) {\n+ throw RuntimeException(\"node \" + childId + \" expected to be at \" + parentId + \".\" + role + \"[\" + index + \"]\" + \" but was \" + o.sourceParentId + \".\" + o.sourceRole + \"[\" + o.sourceIndex + \"]\")\n+ }\n+ DeleteNodeOp(o.targetParentId, o.targetRole, o.targetIndex, childId)\n+ } else if (parentId == o.targetParentId && role == o.targetRole) {\n+ withIndex(o.adjustIndex(parentId, role, index))\n+ } else if (parentId == o.sourceParentId && role == o.sourceRole) {\n+ if (o.sourceIndex == index) {\n+ throw RuntimeException(\"Node at \" + parentId + \".\" + role + \"[\" + index + \"] is expected to be \" + childId + \", but was \" + o.childId)\n+ } else {\n+ withIndex(o.adjustIndex(parentId, role, index))\n+ }\n+ } else {\n+ this\n+ }\n+ } else if (previous is SetPropertyOp) {\n+ this\n+ } else if (previous is SetReferenceOp) {\n+ this\n+ } else if (previous is NoOp) {\n+ this\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + previous!!.javaClass.getName())\n+ }\n+ }\n+\n+ override fun adjustIndex(otherParentId: Long, otherRole: String?, otherIndex: Int): Int {\n+ var adjustedIndex = otherIndex\n+ if (otherParentId == parentId && otherRole == role && index < otherIndex) {\n+ adjustedIndex--\n+ }\n+ return adjustedIndex\n+ }\n+\n+ override fun toString(): String {\n+ return MessageFormat.format(\"DeleteNodeOp {0}, {1}.{2}[{3}]\", java.lang.Long.toHexString(childId), java.lang.Long.toHexString(parentId), role, index)\n+ }\n+\n+ inner class Applied(private val concept: IConcept) : AbstractOperation.Applied(), IAppliedOperation {\n+ override val originalOp: IOperation\n+ get() = this@DeleteNodeOp\n+\n+ override fun invert(): IOperation? {\n+ return AddNewChildOp(parentId, role, index, childId, concept)\n+ }\n+\n+ override fun toString(): String {\n+ return super.toString() + \", concept: \" + concept\n+ }\n+\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/operations/MoveNodeOp.java", "new_path": "model-client/src/main/java/org/modelix/model/operations/MoveNodeOp.java", "diff": "@@ -43,9 +43,9 @@ public class MoveNodeOp extends AbstractOperation implements IModifiesChildrenOp\nreturn withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex));\n} else if (previous instanceof DeleteNodeOp) {\nDeleteNodeOp o = ((DeleteNodeOp) previous);\n- if (Objects.equals(o.parentId, sourceParentId) && Objects.equals(o.role, sourceRole) && Objects.equals(o.index, sourceIndex)) {\n- if (!(Objects.equals(o.childId, childId))) {\n- throw new RuntimeException(sourceParentId + \".\" + sourceRole + \"[\" + sourceIndex + \"] expected to be \" + childId + \", but was \" + o.childId);\n+ if (Objects.equals(o.getParentId(), sourceParentId) && Objects.equals(o.getRole(), sourceRole) && Objects.equals(o.getIndex(), sourceIndex)) {\n+ if (!(Objects.equals(o.getChildId(), childId))) {\n+ throw new RuntimeException(sourceParentId + \".\" + sourceRole + \"[\" + sourceIndex + \"] expected to be \" + childId + \", but was \" + o.getChildId());\n}\nreturn new NoOp();\n} else {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/operations/SetPropertyOp.java", "new_path": "model-client/src/main/java/org/modelix/model/operations/SetPropertyOp.java", "diff": "@@ -32,7 +32,7 @@ public class SetPropertyOp extends AbstractOperation {\nreturn this;\n} else if (previous instanceof DeleteNodeOp) {\nDeleteNodeOp o = ((DeleteNodeOp) previous);\n- if (nodeId == o.childId) {\n+ if (nodeId == o.getChildId()) {\nreturn new NoOp();\n} else {\nreturn this;\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/operations/SetReferenceOp.java", "new_path": "model-client/src/main/java/org/modelix/model/operations/SetReferenceOp.java", "diff": "@@ -33,7 +33,7 @@ public class SetReferenceOp extends AbstractOperation {\nreturn this;\n} else if (previous instanceof DeleteNodeOp) {\nDeleteNodeOp o = ((DeleteNodeOp) previous);\n- if (sourceId == o.parentId) {\n+ if (sourceId == o.getParentId()) {\nreturn new NoOp();\n} else {\nreturn this;\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "new_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "diff": "@@ -34,7 +34,7 @@ public class OperationSerializer {\nINSTANCE.registerSerializer(DeleteNodeOp.class, new Serializer<DeleteNodeOp>() {\n@Override\npublic String serialize(DeleteNodeOp op) {\n- return SerializationUtil.longToHex(op.parentId) + SEPARATOR + SerializationUtil.escape(op.role) + SEPARATOR + op.index + SEPARATOR + SerializationUtil.longToHex(op.childId);\n+ return SerializationUtil.longToHex(op.getParentId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + op.getIndex() + SEPARATOR + SerializationUtil.longToHex(op.getChildId());\n}\n@Override\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate DeleteNodeOp
426,504
01.08.2020 14:42:05
-7,200
19e172105040322a76a3b5508f34a96c216108df
translate MoveNodeOp
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/MoveNodeOp.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IWriteTransaction;\n-import java.util.Objects;\n-import java.text.MessageFormat;\n-\n-public class MoveNodeOp extends AbstractOperation implements IModifiesChildrenOp {\n-\n- public final long childId;\n-\n- public final long sourceParentId;\n- public final String sourceRole;\n- public final int sourceIndex;\n-\n- public final long targetParentId;\n- public final String targetRole;\n- public final int targetIndex;\n-\n- public MoveNodeOp(long childId, long sourceParentId, String sourceRole, int sourceIndex, long targetParentId, String targetRole, int targetIndex) {\n- this.childId = childId;\n- this.sourceParentId = sourceParentId;\n- this.sourceRole = sourceRole;\n- this.sourceIndex = sourceIndex;\n- this.targetParentId = targetParentId;\n- this.targetRole = targetRole;\n- this.targetIndex = targetIndex;\n- }\n-\n- public MoveNodeOp withIndex(int newSourceIndex, int newTargetIndex) {\n- return (newSourceIndex == sourceIndex && newTargetIndex == targetIndex ? this : new MoveNodeOp(childId, sourceParentId, sourceRole, newSourceIndex, targetParentId, targetRole, newTargetIndex));\n- }\n-\n- @Override\n- public IAppliedOperation apply(IWriteTransaction transaction) {\n- transaction.moveChild(targetParentId, targetRole, targetIndex, childId);\n- return new Applied();\n- }\n-\n- @Override\n- public IOperation transform(IOperation previous) {\n- if (previous instanceof AddNewChildOp) {\n- AddNewChildOp o = ((AddNewChildOp) previous);\n- return withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex));\n- } else if (previous instanceof DeleteNodeOp) {\n- DeleteNodeOp o = ((DeleteNodeOp) previous);\n- if (Objects.equals(o.getParentId(), sourceParentId) && Objects.equals(o.getRole(), sourceRole) && Objects.equals(o.getIndex(), sourceIndex)) {\n- if (!(Objects.equals(o.getChildId(), childId))) {\n- throw new RuntimeException(sourceParentId + \".\" + sourceRole + \"[\" + sourceIndex + \"] expected to be \" + childId + \", but was \" + o.getChildId());\n- }\n- return new NoOp();\n- } else {\n- return withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex));\n- }\n- } else if (previous instanceof MoveNodeOp) {\n- MoveNodeOp o = ((MoveNodeOp) previous);\n- return withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex));\n- } else if (previous instanceof SetPropertyOp) {\n- return this;\n- } else if (previous instanceof SetReferenceOp) {\n- return this;\n- } else if (previous instanceof NoOp) {\n- return this;\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + previous.getClass().getName());\n- }\n- }\n-\n- @Override\n- public int adjustIndex(long otherParentId, String otherRole, int otherIndex) {\n- int adjustedIndex = otherIndex;\n- if (Objects.equals(otherParentId, sourceParentId) && Objects.equals(otherRole, sourceRole) && sourceIndex < otherIndex) {\n- adjustedIndex--;\n- }\n- if (Objects.equals(otherParentId, targetParentId) && Objects.equals(otherRole, targetRole) && targetIndex <= otherIndex) {\n- adjustedIndex++;\n- }\n- return adjustedIndex;\n- }\n-\n- @Override\n- public String toString() {\n- return MessageFormat.format(\"MoveNodeOp {0}, {1}.{2}[{3}]->{4}.{5}[{6}]\", Long.toHexString(childId), Long.toHexString(sourceParentId), sourceRole, sourceIndex, Long.toHexString(targetParentId), targetRole, targetIndex);\n- }\n-\n- public class Applied extends AbstractOperation.Applied implements IAppliedOperation {\n- public Applied() {\n- }\n- @Override\n- public IOperation getOriginalOp() {\n- return MoveNodeOp.this;\n- }\n-\n- @Override\n- public IOperation invert() {\n- return new MoveNodeOp(childId, targetParentId, targetRole, targetIndex, sourceParentId, sourceRole, sourceIndex);\n- }\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/MoveNodeOp.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.modelix.model.api.IWriteTransaction\n+import org.modelix.model.operations.MoveNodeOp\n+import java.text.MessageFormat\n+\n+class MoveNodeOp(val childId: Long, val sourceParentId: Long, val sourceRole: String, val sourceIndex: Int, val targetParentId: Long, val targetRole: String, val targetIndex: Int) : AbstractOperation(), IModifiesChildrenOp {\n+ fun withIndex(newSourceIndex: Int, newTargetIndex: Int): MoveNodeOp {\n+ return if (newSourceIndex == sourceIndex && newTargetIndex == targetIndex) this else MoveNodeOp(childId, sourceParentId, sourceRole, newSourceIndex, targetParentId, targetRole, newTargetIndex)\n+ }\n+\n+ override fun apply(transaction: IWriteTransaction?): IAppliedOperation? {\n+ transaction!!.moveChild(targetParentId, targetRole, targetIndex, childId)\n+ return Applied()\n+ }\n+\n+ override fun transform(previous: IOperation?): IOperation? {\n+ return if (previous is AddNewChildOp) {\n+ val o = previous\n+ withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex))\n+ } else if (previous is DeleteNodeOp) {\n+ val o = previous\n+ if (o.parentId == sourceParentId && o.role == sourceRole && o.index == sourceIndex) {\n+ if (o.childId != childId) {\n+ throw RuntimeException(sourceParentId.toString() + \".\" + sourceRole + \"[\" + sourceIndex + \"] expected to be \" + childId + \", but was \" + o.childId)\n+ }\n+ NoOp()\n+ } else {\n+ withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex))\n+ }\n+ } else if (previous is MoveNodeOp) {\n+ val o = previous\n+ withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex))\n+ } else if (previous is SetPropertyOp) {\n+ this\n+ } else if (previous is SetReferenceOp) {\n+ this\n+ } else if (previous is NoOp) {\n+ this\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + previous!!.javaClass.getName())\n+ }\n+ }\n+\n+ override fun adjustIndex(otherParentId: Long, otherRole: String?, otherIndex: Int): Int {\n+ var adjustedIndex = otherIndex\n+ if (otherParentId == sourceParentId && otherRole == sourceRole && sourceIndex < otherIndex) {\n+ adjustedIndex--\n+ }\n+ if (otherParentId == targetParentId && otherRole == targetRole && targetIndex <= otherIndex) {\n+ adjustedIndex++\n+ }\n+ return adjustedIndex\n+ }\n+\n+ override fun toString(): String {\n+ return MessageFormat.format(\"MoveNodeOp {0}, {1}.{2}[{3}]->{4}.{5}[{6}]\", java.lang.Long.toHexString(childId), java.lang.Long.toHexString(sourceParentId), sourceRole, sourceIndex, java.lang.Long.toHexString(targetParentId), targetRole, targetIndex)\n+ }\n+\n+ inner class Applied : AbstractOperation.Applied(), IAppliedOperation {\n+ override val originalOp: IOperation\n+ get() = this@MoveNodeOp\n+\n+ override fun invert(): IOperation? {\n+ return MoveNodeOp(childId, targetParentId, targetRole, targetIndex, sourceParentId, sourceRole, sourceIndex)\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "new_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "diff": "@@ -46,7 +46,7 @@ public class OperationSerializer {\nINSTANCE.registerSerializer(MoveNodeOp.class, new Serializer<MoveNodeOp>() {\n@Override\npublic String serialize(MoveNodeOp op) {\n- return SerializationUtil.longToHex(op.childId) + SEPARATOR + SerializationUtil.longToHex(op.sourceParentId) + SEPARATOR + SerializationUtil.escape(op.sourceRole) + SEPARATOR + op.sourceIndex + SEPARATOR + SerializationUtil.longToHex(op.targetParentId) + SEPARATOR + SerializationUtil.escape(op.targetRole) + SEPARATOR + op.targetIndex;\n+ return SerializationUtil.longToHex(op.getChildId()) + SEPARATOR + SerializationUtil.longToHex(op.getSourceParentId()) + SEPARATOR + SerializationUtil.escape(op.getSourceRole()) + SEPARATOR + op.getSourceIndex() + SEPARATOR + SerializationUtil.longToHex(op.getTargetParentId()) + SEPARATOR + SerializationUtil.escape(op.getTargetRole()) + SEPARATOR + op.getTargetIndex();\n}\n@Override\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate MoveNodeOp
426,504
01.08.2020 14:42:57
-7,200
ad34993a477f13a4110800654f4477ae1808ef4e
translate NoOp
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/NoOp.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IWriteTransaction;\n-\n-public class NoOp extends AbstractOperation implements IAppliedOperation {\n-\n-\n- @Override\n- public IAppliedOperation apply(IWriteTransaction transaction) {\n- return this;\n- }\n-\n- @Override\n- public IOperation transform(IOperation previous) {\n- return null;\n- }\n-\n- @Override\n- public IOperation getOriginalOp() {\n- return this;\n- }\n-\n- @Override\n- public IOperation invert() {\n- return this;\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/NoOp.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.modelix.model.api.IWriteTransaction\n+\n+class NoOp : AbstractOperation(), IAppliedOperation {\n+ override fun apply(transaction: IWriteTransaction?): IAppliedOperation? {\n+ return this\n+ }\n+\n+ override fun transform(previous: IOperation?): IOperation? {\n+ return null\n+ }\n+\n+ override val originalOp: IOperation\n+ get() = this\n+\n+ override fun invert(): IOperation? {\n+ return this\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate NoOp
426,504
01.08.2020 14:44:14
-7,200
7edb9d1b8381024d8ce89f43bccc99a1c03b92e1
translate OTWriteTransaction
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IConcept;\n-import org.modelix.model.api.INode;\n-import org.modelix.model.api.INodeReference;\n-import org.modelix.model.api.IBranch;\n-import org.modelix.model.api.IIdGenerator;\n-import org.modelix.model.api.ITree;\n-import org.modelix.model.api.IWriteTransaction;\n-import org.modelix.model.api.PNodeAdapter;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.modelix.model.util.StreamUtils;\n-\n-import java.util.stream.LongStream;\n-\n-public class OTWriteTransaction implements IWriteTransaction {\n- private static final Logger LOG = LogManager.getLogger(OTWriteTransaction.class);\n-\n- private IWriteTransaction transaction;\n- private OTBranch otBranch;\n- protected IIdGenerator idGenerator;\n-\n- public OTWriteTransaction(IWriteTransaction transaction, OTBranch otBranch, IIdGenerator idGenerator) {\n- this.otBranch = otBranch;\n- this.transaction = transaction;\n- this.idGenerator = idGenerator;\n- }\n-\n- protected void apply(IOperation op) {\n- if (LOG.isDebugEnabled()) {\n- LOG.debug(\"apply: \" + op);\n- }\n- IAppliedOperation appliedOp = op.apply(transaction);\n- otBranch.operationApplied(appliedOp);\n- }\n-\n- @Override\n- public void moveChild(long newParentId, String newRole, int newIndex, long childId) {\n- long oldparent = getParent(childId);\n- String oldRole = getRole(childId);\n- int oldIndex = StreamUtils.INSTANCE.indexOf(getChildren(oldparent, oldRole), childId);\n- if (newIndex == -1) {\n- newIndex = (int) getChildren(newParentId, newRole).count();\n- }\n- apply(new MoveNodeOp(childId, oldparent, oldRole, oldIndex, newParentId, newRole, newIndex));\n- }\n-\n- @Override\n- public void setProperty(long nodeId, String role, String value) {\n- apply(new SetPropertyOp(nodeId, role, value));\n- }\n-\n- @Override\n- public void setReferenceTarget(long sourceId, String role, INodeReference target) {\n- apply(new SetReferenceOp(sourceId, role, target));\n- }\n-\n- @Override\n- public void addNewChild(long parentId, String role, int index, long childId, IConcept concept) {\n- if (index == -1) {\n- index = (int) getChildren(parentId, role).count();\n- }\n- apply(new AddNewChildOp(parentId, role, index, childId, concept));\n- }\n-\n- @Override\n- public void deleteNode(long nodeId) {\n- long parent = getParent(nodeId);\n- String role = getRole(nodeId);\n- int index = StreamUtils.INSTANCE.indexOf(getChildren(parent, role), nodeId);\n- apply(new DeleteNodeOp(parent, role, index, nodeId));\n- }\n-\n- @Override\n- public long addNewChild(long parentId, String role, int index, IConcept concept) {\n- long childId = idGenerator.generate();\n- addNewChild(parentId, role, index, childId, concept);\n- return childId;\n- }\n- @Override\n- public boolean containsNode(long nodeId) {\n- return transaction.containsNode(nodeId);\n- }\n- @Override\n- public LongStream getAllChildren(long parentId) {\n- return transaction.getAllChildren(parentId);\n- }\n- @Override\n- public IBranch getBranch() {\n- return otBranch;\n- }\n- @Override\n- public LongStream getChildren(long parentId, String role) {\n- return transaction.getChildren(parentId, role);\n- }\n- @Override\n- public IConcept getConcept(long nodeId) {\n- return transaction.getConcept(nodeId);\n- }\n- @Override\n- public long getParent(long nodeId) {\n- return transaction.getParent(nodeId);\n- }\n- @Override\n- public String getProperty(long nodeId, String role) {\n- return transaction.getProperty(nodeId, role);\n- }\n- @Override\n- public INodeReference getReferenceTarget(long sourceId, String role) {\n- return transaction.getReferenceTarget(sourceId, role);\n- }\n- @Override\n- public String getRole(long nodeId) {\n- return transaction.getRole(nodeId);\n- }\n- @Override\n- public ITree getTree() {\n- return transaction.getTree();\n- }\n- @Override\n- public void setTree(ITree tree) {\n- throw new UnsupportedOperationException();\n- }\n-\n- protected INode wrap(INode node) {\n- return (node instanceof PNodeAdapter ? new PNodeAdapter(((PNodeAdapter) node).getNodeId(), otBranch) : node);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.apache.log4j.LogManager\n+import org.modelix.model.api.*\n+import org.modelix.model.util.StreamUtils.indexOf\n+import java.util.stream.LongStream\n+\n+class OTWriteTransaction(private val transaction: IWriteTransaction, private val otBranch: OTBranch, protected var idGenerator: IIdGenerator) : IWriteTransaction {\n+ protected fun apply(op: IOperation) {\n+ if (LOG.isDebugEnabled) {\n+ LOG.debug(\"apply: $op\")\n+ }\n+ val appliedOp = op.apply(transaction)\n+ otBranch.operationApplied(appliedOp)\n+ }\n+\n+ override fun moveChild(newParentId: Long, newRole: String?, newIndex: Int, childId: Long) {\n+ var newIndex = newIndex\n+ val oldparent = getParent(childId)\n+ val oldRole = getRole(childId)\n+ val oldIndex = indexOf(getChildren(oldparent, oldRole)!!, childId)\n+ if (newIndex == -1) {\n+ newIndex = getChildren(newParentId, newRole)!!.count().toInt()\n+ }\n+ apply(MoveNodeOp(childId, oldparent, oldRole!!, oldIndex, newParentId, newRole!!, newIndex))\n+ }\n+\n+ override fun setProperty(nodeId: Long, role: String?, value: String?) {\n+ apply(SetPropertyOp(nodeId, role, value))\n+ }\n+\n+ override fun setReferenceTarget(sourceId: Long, role: String?, target: INodeReference?) {\n+ apply(SetReferenceOp(sourceId, role, target))\n+ }\n+\n+ override fun addNewChild(parentId: Long, role: String?, index: Int, childId: Long, concept: IConcept?) {\n+ var index = index\n+ if (index == -1) {\n+ index = getChildren(parentId, role)!!.count().toInt()\n+ }\n+ apply(AddNewChildOp(parentId, role!!, index, childId, concept!!))\n+ }\n+\n+ override fun deleteNode(nodeId: Long) {\n+ val parent = getParent(nodeId)\n+ val role = getRole(nodeId)\n+ val index = indexOf(getChildren(parent, role)!!, nodeId)\n+ apply(DeleteNodeOp(parent, role!!, index, nodeId))\n+ }\n+\n+ override fun addNewChild(parentId: Long, role: String?, index: Int, concept: IConcept?): Long {\n+ val childId = idGenerator.generate()\n+ addNewChild(parentId, role, index, childId, concept)\n+ return childId\n+ }\n+\n+ override fun containsNode(nodeId: Long): Boolean {\n+ return transaction.containsNode(nodeId)\n+ }\n+\n+ override fun getAllChildren(parentId: Long): LongStream? {\n+ return transaction.getAllChildren(parentId)\n+ }\n+\n+ override val branch: IBranch\n+ get() = otBranch\n+\n+ override fun getChildren(parentId: Long, role: String?): LongStream? {\n+ return transaction.getChildren(parentId, role)\n+ }\n+\n+ override fun getConcept(nodeId: Long): IConcept? {\n+ return transaction.getConcept(nodeId)\n+ }\n+\n+ override fun getParent(nodeId: Long): Long {\n+ return transaction.getParent(nodeId)\n+ }\n+\n+ override fun getProperty(nodeId: Long, role: String?): String? {\n+ return transaction.getProperty(nodeId, role)\n+ }\n+\n+ override fun getReferenceTarget(sourceId: Long, role: String?): INodeReference? {\n+ return transaction.getReferenceTarget(sourceId, role)\n+ }\n+\n+ override fun getRole(nodeId: Long): String? {\n+ return transaction.getRole(nodeId)\n+ }\n+\n+ override var tree: ITree?\n+ get() = transaction.tree\n+ set(tree) {\n+ throw UnsupportedOperationException()\n+ }\n+\n+ protected fun wrap(node: INode?): INode {\n+ return if (node is PNodeAdapter) PNodeAdapter(node.nodeId, otBranch) else node!!\n+ }\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(OTWriteTransaction::class.java)\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate OTWriteTransaction
426,504
01.08.2020 14:45:35
-7,200
591aef37ebc94d459d8d51c3c4faf7961486b94b
translate SetPropertyOp
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.kt", "new_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "@@ -26,7 +26,7 @@ class OTWriteTransaction(private val transaction: IWriteTransaction, private val\n}\noverride fun setProperty(nodeId: Long, role: String?, value: String?) {\n- apply(SetPropertyOp(nodeId, role, value))\n+ apply(SetPropertyOp(nodeId, role!!, value!!))\n}\noverride fun setReferenceTarget(sourceId: Long, role: String?, target: INodeReference?) {\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/SetPropertyOp.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IWriteTransaction;\n-import java.text.MessageFormat;\n-\n-public class SetPropertyOp extends AbstractOperation {\n-\n- public final long nodeId;\n- public final String role;\n- public final String value;\n-\n- public SetPropertyOp(long nodeId, String role, String value) {\n- this.nodeId = nodeId;\n- this.role = role;\n- this.value = value;\n- }\n-\n- @Override\n- public IAppliedOperation apply(IWriteTransaction transaction) {\n- String oldValue = transaction.getProperty(nodeId, role);\n- transaction.setProperty(nodeId, role, value);\n- return new Applied(oldValue);\n- }\n-\n- @Override\n- public IOperation transform(IOperation previous) {\n- if (previous instanceof SetPropertyOp) {\n- return this;\n- } else if (previous instanceof SetReferenceOp) {\n- return this;\n- } else if (previous instanceof AddNewChildOp) {\n- return this;\n- } else if (previous instanceof DeleteNodeOp) {\n- DeleteNodeOp o = ((DeleteNodeOp) previous);\n- if (nodeId == o.getChildId()) {\n- return new NoOp();\n- } else {\n- return this;\n- }\n- } else if (previous instanceof MoveNodeOp) {\n- return this;\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + previous.getClass().getName());\n- }\n- }\n-\n- @Override\n- public String toString() {\n- return MessageFormat.format(\"SetPropertOp {0}.{1} = {2}\", Long.toHexString(nodeId), role, value);\n- }\n-\n- public class Applied extends AbstractOperation.Applied implements IAppliedOperation {\n- private String oldValue;\n-\n- public Applied(String oldValue) {\n- this.oldValue = oldValue;\n- }\n-\n- @Override\n- public IOperation getOriginalOp() {\n- return SetPropertyOp.this;\n- }\n-\n- @Override\n- public IOperation invert() {\n- return new SetPropertyOp(nodeId, role, oldValue);\n- }\n-\n- @Override\n- public String toString() {\n- return super.toString() + \", oldValue: \" + oldValue;\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/SetPropertyOp.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.modelix.model.api.IWriteTransaction\n+import org.modelix.model.operations.SetPropertyOp\n+import java.text.MessageFormat\n+\n+class SetPropertyOp(val nodeId: Long, val role: String, val value: String) : AbstractOperation() {\n+ override fun apply(transaction: IWriteTransaction?): IAppliedOperation? {\n+ val oldValue = transaction!!.getProperty(nodeId, role)\n+ transaction.setProperty(nodeId, role, value)\n+ return Applied(oldValue!!)\n+ }\n+\n+ override fun transform(previous: IOperation?): IOperation? {\n+ return if (previous is SetPropertyOp) {\n+ this\n+ } else if (previous is SetReferenceOp) {\n+ this\n+ } else if (previous is AddNewChildOp) {\n+ this\n+ } else if (previous is DeleteNodeOp) {\n+ if (nodeId == previous.childId) {\n+ NoOp()\n+ } else {\n+ this\n+ }\n+ } else if (previous is MoveNodeOp) {\n+ this\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + previous!!.javaClass.getName())\n+ }\n+ }\n+\n+ override fun toString(): String {\n+ return MessageFormat.format(\"SetPropertOp {0}.{1} = {2}\", java.lang.Long.toHexString(nodeId), role, value)\n+ }\n+\n+ inner class Applied(private val oldValue: String) : AbstractOperation.Applied(), IAppliedOperation {\n+ override val originalOp: IOperation\n+ get() = this@SetPropertyOp\n+\n+ override fun invert(): IOperation? {\n+ return SetPropertyOp(nodeId, role, oldValue)\n+ }\n+\n+ override fun toString(): String {\n+ return super.toString() + \", oldValue: \" + oldValue\n+ }\n+\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "new_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "diff": "@@ -69,7 +69,7 @@ public class OperationSerializer {\nINSTANCE.registerSerializer(SetPropertyOp.class, new Serializer<SetPropertyOp>() {\n@Override\npublic String serialize(SetPropertyOp op) {\n- return SerializationUtil.longToHex(op.nodeId) + SEPARATOR + SerializationUtil.escape(op.role) + SEPARATOR + SerializationUtil.escape(op.value);\n+ return SerializationUtil.longToHex(op.getNodeId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + SerializationUtil.escape(op.getValue());\n}\n@Override\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate SetPropertyOp
426,504
01.08.2020 14:45:58
-7,200
564706108743cdeaad207e7e7abb69e912ddd199
translate SetReferenceOp
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.kt", "new_path": "model-client/src/main/java/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "@@ -30,7 +30,7 @@ class OTWriteTransaction(private val transaction: IWriteTransaction, private val\n}\noverride fun setReferenceTarget(sourceId: Long, role: String?, target: INodeReference?) {\n- apply(SetReferenceOp(sourceId, role, target))\n+ apply(SetReferenceOp(sourceId, role!!, target!!))\n}\noverride fun addNewChild(parentId: Long, role: String?, index: Int, childId: Long, concept: IConcept?) {\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/SetReferenceOp.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.INodeReference;\n-import org.modelix.model.api.IWriteTransaction;\n-import java.text.MessageFormat;\n-\n-public class SetReferenceOp extends AbstractOperation {\n-\n- public final long sourceId;\n- public final String role;\n- public final INodeReference target;\n-\n- public SetReferenceOp(long sourceId, String role, INodeReference target) {\n- this.sourceId = sourceId;\n- this.role = role;\n- this.target = target;\n- }\n-\n- @Override\n- public IAppliedOperation apply(IWriteTransaction transaction) {\n- INodeReference oldValue = transaction.getReferenceTarget(sourceId, role);\n- transaction.setReferenceTarget(sourceId, role, target);\n- return new Applied(oldValue);\n- }\n-\n- @Override\n- public IOperation transform(IOperation previous) {\n- if (previous instanceof SetPropertyOp) {\n- return this;\n- } else if (previous instanceof SetReferenceOp) {\n- return this;\n- } else if (previous instanceof AddNewChildOp) {\n- return this;\n- } else if (previous instanceof DeleteNodeOp) {\n- DeleteNodeOp o = ((DeleteNodeOp) previous);\n- if (sourceId == o.getParentId()) {\n- return new NoOp();\n- } else {\n- return this;\n- }\n- } else if (previous instanceof MoveNodeOp) {\n- return this;\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + previous.getClass().getName());\n- }\n- }\n-\n- @Override\n- public String toString() {\n- return MessageFormat.format(\"SetReferenceOp {0}.{1} = {2}\", Long.toHexString(sourceId), role, target);\n- }\n-\n- public class Applied extends AbstractOperation.Applied implements IAppliedOperation {\n- private INodeReference oldValue;\n-\n- public Applied(INodeReference oldValue) {\n- this.oldValue = oldValue;\n- }\n-\n- @Override\n- public IOperation getOriginalOp() {\n- return SetReferenceOp.this;\n- }\n-\n- @Override\n- public IOperation invert() {\n- return new SetReferenceOp(sourceId, role, oldValue);\n- }\n-\n- @Override\n- public String toString() {\n- return super.toString() + \", oldValue: \" + oldValue;\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/operations/SetReferenceOp.kt", "diff": "+package org.modelix.model.operations\n+\n+import org.modelix.model.api.INodeReference\n+import org.modelix.model.api.IWriteTransaction\n+import org.modelix.model.operations.SetReferenceOp\n+import java.text.MessageFormat\n+\n+class SetReferenceOp(val sourceId: Long, val role: String, val target: INodeReference) : AbstractOperation() {\n+ override fun apply(transaction: IWriteTransaction?): IAppliedOperation? {\n+ val oldValue = transaction!!.getReferenceTarget(sourceId, role)\n+ transaction.setReferenceTarget(sourceId, role, target)\n+ return Applied(oldValue!!)\n+ }\n+\n+ override fun transform(previous: IOperation?): IOperation? {\n+ return if (previous is SetPropertyOp) {\n+ this\n+ } else if (previous is SetReferenceOp) {\n+ this\n+ } else if (previous is AddNewChildOp) {\n+ this\n+ } else if (previous is DeleteNodeOp) {\n+ if (sourceId == previous.parentId) {\n+ NoOp()\n+ } else {\n+ this\n+ }\n+ } else if (previous is MoveNodeOp) {\n+ this\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + previous!!.javaClass.getName())\n+ }\n+ }\n+\n+ override fun toString(): String {\n+ return MessageFormat.format(\"SetReferenceOp {0}.{1} = {2}\", java.lang.Long.toHexString(sourceId), role, target)\n+ }\n+\n+ inner class Applied(private val oldValue: INodeReference) : AbstractOperation.Applied(), IAppliedOperation {\n+ override val originalOp: IOperation\n+ get() = this@SetReferenceOp\n+\n+ override fun invert(): IOperation? {\n+ return SetReferenceOp(sourceId, role, oldValue)\n+ }\n+\n+ override fun toString(): String {\n+ return super.toString() + \", oldValue: \" + oldValue\n+ }\n+\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "new_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "diff": "@@ -81,7 +81,7 @@ public class OperationSerializer {\nINSTANCE.registerSerializer(SetReferenceOp.class, new Serializer<SetReferenceOp>() {\n@Override\npublic String serialize(SetReferenceOp op) {\n- return SerializationUtil.longToHex(op.sourceId) + SEPARATOR + SerializationUtil.escape(op.role) + SEPARATOR + serializeReference(op.target);\n+ return SerializationUtil.longToHex(op.getSourceId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + serializeReference(op.getTarget());\n}\n@Override\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate SetReferenceOp
426,504
01.08.2020 14:48:56
-7,200
cd265669489f55eeb97917c990573c7af75b4142
translate SerializationUtil
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/SerializationUtil.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import java.net.URLEncoder;\n-import java.nio.charset.StandardCharsets;\n-import java.net.URLDecoder;\n-\n-public class SerializationUtil {\n- public static String escape(String value) {\n- if (value == null) {\n- return \"%00\";\n- }\n- return URLEncoder.encode(value, StandardCharsets.UTF_8);\n- }\n-\n- public static String unescape(String value) {\n- if (value == null) {\n- return null;\n- }\n- if (\"%00\".equals(value)) {\n- return null;\n- }\n- return URLDecoder.decode(value, StandardCharsets.UTF_8);\n- }\n-\n- public static String longToHex(long value) {\n- return Long.toHexString(value);\n- }\n-\n- public static long longFromHex(String hex) {\n- return Long.parseUnsignedLong(hex, 16);\n- }\n-\n- public static String intToHex(int value) {\n- return Integer.toHexString(value);\n- }\n-\n- public static int intFromHex(String hex) {\n- return Integer.parseUnsignedInt(hex, 16);\n- }\n-\n- public static String nullAsEmptyString(String str) {\n- if (str == null) {\n- return \"\";\n- }\n- if (str.length() == 0) {\n- throw new RuntimeException(\"Empty string not allowed\");\n- }\n- return str;\n- }\n-\n- public static String emptyStringAsNull(String str) {\n- return ((str == null || str.length() == 0) ? null : str);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/SerializationUtil.kt", "diff": "+package org.modelix.model.persistent\n+\n+import java.net.URLDecoder\n+import java.net.URLEncoder\n+import java.nio.charset.StandardCharsets\n+\n+object SerializationUtil {\n+ @JvmStatic\n+ fun escape(value: String?): String {\n+ return if (value == null) {\n+ \"%00\"\n+ } else URLEncoder.encode(value, StandardCharsets.UTF_8)\n+ }\n+\n+ @JvmStatic\n+ fun unescape(value: String?): String? {\n+ if (value == null) {\n+ return null\n+ }\n+ return if (\"%00\" == value) {\n+ null\n+ } else URLDecoder.decode(value, StandardCharsets.UTF_8)\n+ }\n+\n+ @JvmStatic\n+ fun longToHex(value: Long): String {\n+ return java.lang.Long.toHexString(value)\n+ }\n+\n+ @JvmStatic\n+ fun longFromHex(hex: String?): Long {\n+ return java.lang.Long.parseUnsignedLong(hex, 16)\n+ }\n+\n+ @JvmStatic\n+ fun intToHex(value: Int): String {\n+ return Integer.toHexString(value)\n+ }\n+\n+ @JvmStatic\n+ fun intFromHex(hex: String?): Int {\n+ return Integer.parseUnsignedInt(hex, 16)\n+ }\n+\n+ @JvmStatic\n+ fun nullAsEmptyString(str: String?): String {\n+ if (str == null) {\n+ return \"\"\n+ }\n+ if (str.length == 0) {\n+ throw RuntimeException(\"Empty string not allowed\")\n+ }\n+ return str\n+ }\n+\n+ @JvmStatic\n+ fun emptyStringAsNull(str: String?): String? {\n+ return if (str == null || str.length == 0) null else str\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate SerializationUtil
426,504
01.08.2020 14:57:47
-7,200
73495e790aa510b44ce093902c587d89d2398570
convert MapBaseStore
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/MapBaseStore.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import gnu.trove.map.hash.THashMap;\n-import org.modelix.model.IKeyListener;\n-import org.modelix.model.IKeyValueStore;\n-\n-import java.util.LinkedHashMap;\n-import java.util.Map;\n-\n-public class MapBaseStore implements IKeyValueStore {\n-\n- private Map<String, String> map = new THashMap<String, String>();\n-\n- @Override\n- public String get(String key) {\n- return map.get(key);\n- }\n-\n- @Override\n- public void put(String key, String value) {\n- map.put(key, value);\n- }\n-\n- @Override\n- public Map<String, String> getAll(Iterable<String> keys) {\n- Map<String, String> result = new LinkedHashMap<>(16, (float) 0.75, false);\n- for (String key : keys) {\n- result.put(key, map.get(key));\n- }\n- return result;\n- }\n-\n- @Override\n- public void putAll(Map<String, String> entries) {\n- map.putAll(entries);\n- }\n-\n- @Override\n- public void prefetch(String key) {\n- }\n-\n- public Iterable<Map.Entry<String, String>> getEntries() {\n- return map.entrySet();\n- }\n-\n- @Override\n- public void listen(final String key, final IKeyListener listener) {\n- throw new UnsupportedOperationException();\n- }\n- @Override\n- public void removeListener(final String key, final IKeyListener listener) {\n- throw new UnsupportedOperationException();\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/MapBaseStore.kt", "diff": "+package org.modelix.model.persistent\n+\n+import gnu.trove.map.hash.THashMap\n+import org.modelix.model.IKeyListener\n+import org.modelix.model.IKeyValueStore\n+import java.util.*\n+\n+class MapBaseStore : IKeyValueStore {\n+ private val map: MutableMap<String?, String?> = THashMap()\n+ override fun get(key: String?): String? {\n+ return map[key]\n+ }\n+\n+ override fun put(key: String?, value: String?) {\n+ map[key] = value\n+ }\n+\n+ override fun getAll(keys: Iterable<String?>?): Map<String?, String?>? {\n+ val result: MutableMap<String?, String?> = LinkedHashMap(16, 0.75.toFloat(), false)\n+ for (key in keys!!) {\n+ result[key] = map[key]\n+ }\n+ return result\n+ }\n+\n+ override fun putAll(entries: Map<String?, String?>?) {\n+ map.putAll(entries!!)\n+ }\n+\n+ override fun prefetch(key: String?) {}\n+ val entries: Iterable<Map.Entry<String?, String?>>\n+ get() = map.entries\n+\n+ override fun listen(key: String?, listener: IKeyListener?) {\n+ throw UnsupportedOperationException()\n+ }\n+\n+ override fun removeListener(key: String?, listener: IKeyListener?) {\n+ throw UnsupportedOperationException()\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert MapBaseStore
426,504
01.08.2020 15:01:15
-7,200
7d92c4f92a2e16dbfd3cdf5040896f95b5019729
convert COWArrays
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "diff": "@@ -178,13 +178,13 @@ public class CLTree implements ITree {\nlong[] newChildrenArray = parent.getData().getChildrenIdArray();\nif (index == -1) {\n- newChildrenArray = COWArrays.add(newChildrenArray, childData.getId());\n+ newChildrenArray = COWArrays.INSTANCE.add(newChildrenArray, childData.getId());\n} else {\nOptionalLong anchor = getChildren(parentId, role).skip(index).findFirst();\nif (anchor.isEmpty()) {\n- newChildrenArray = COWArrays.add(newChildrenArray, childData.getId());\n+ newChildrenArray = COWArrays.INSTANCE.add(newChildrenArray, childData.getId());\n} else {\n- newChildrenArray = COWArrays.insert(\n+ newChildrenArray = COWArrays.INSTANCE.insert(\nnewChildrenArray,\nCOWArrays.indexOf(newChildrenArray, anchor.getAsLong()),\nchildData.getId());\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPNode.java", "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPNode.java", "diff": "@@ -179,14 +179,14 @@ public class CPNode extends CPElement {\nif (index < 0) {\nreturn this;\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, COWArrays.removeAt(propertyRoles, index), COWArrays.removeAt(propertyValues, index), referenceRoles, referenceTargets);\n+ return create(id, concept, parentId, roleInParent, childrenIds, COWArrays.INSTANCE.removeAt(propertyRoles, index), COWArrays.INSTANCE.removeAt(propertyValues, index), referenceRoles, referenceTargets);\n}\n} else {\nif (index < 0) {\nindex = -(index + 1);\n- return create(id, concept, parentId, roleInParent, childrenIds, COWArrays.insert(propertyRoles, index, role), COWArrays.insert(propertyValues, index, value), referenceRoles, referenceTargets);\n+ return create(id, concept, parentId, roleInParent, childrenIds, COWArrays.INSTANCE.insert(propertyRoles, index, role), COWArrays.INSTANCE.insert(propertyValues, index, value), referenceRoles, referenceTargets);\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, COWArrays.set(propertyValues, index, value), referenceRoles, referenceTargets);\n+ return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, COWArrays.INSTANCE.set(propertyValues, index, value), referenceRoles, referenceTargets);\n}\n}\n}\n@@ -197,14 +197,14 @@ public class CPNode extends CPElement {\nif (index < 0) {\nreturn this;\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, COWArrays.removeAt(referenceRoles, index), COWArrays.removeAt(referenceTargets, index));\n+ return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.removeAt(referenceRoles, index), COWArrays.INSTANCE.removeAt(referenceTargets, index));\n}\n} else {\nif (index < 0) {\nindex = -(index + 1);\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, COWArrays.insert(referenceRoles, index, role), COWArrays.insert(referenceTargets, index, target));\n+ return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.insert(referenceRoles, index, role), COWArrays.INSTANCE.insert(referenceTargets, index, target));\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, COWArrays.set(referenceTargets, index, target));\n+ return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, COWArrays.INSTANCE.set(referenceTargets, index, target));\n}\n}\n}\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/util/pmap/COWArrays.java", "new_path": null, "diff": "-package org.modelix.model.util.pmap;\n-\n-import java.lang.reflect.Array;\n-import java.util.Arrays;\n-import java.util.Objects;\n-\n-public class COWArrays {\n- public static <T> T[] insert(T[] array, int index, T element) {\n- T[] newArray = ((T[]) Array.newInstance(array.getClass().getComponentType(), array.length + 1));\n- System.arraycopy(array, 0, newArray, 0, index);\n- newArray[index] = element;\n- System.arraycopy(array, index, newArray, index + 1, array.length - index);\n- return newArray;\n- }\n-\n- public static long[] insert(long[] array, int index, long element) {\n- long[] newArray = new long[array.length + 1];\n- System.arraycopy(array, 0, newArray, 0, index);\n- newArray[index] = element;\n- System.arraycopy(array, index, newArray, index + 1, array.length - index);\n- return newArray;\n- }\n-\n- public static long[] insert(long[] array, int index, long[] elements) {\n- long[] newArray = new long[array.length + elements.length];\n- System.arraycopy(array, 0, newArray, 0, index);\n- System.arraycopy(elements, 0, newArray, index, elements.length);\n- System.arraycopy(array, index, newArray, index + elements.length, array.length - index);\n- return newArray;\n- }\n-\n- public static <T> T[] removeAt(T[] array, int index) {\n- T[] newArray = ((T[]) Array.newInstance(array.getClass().getComponentType(), array.length - 1));\n- System.arraycopy(array, 0, newArray, 0, index);\n- System.arraycopy(array, index + 1, newArray, index, array.length - index - 1);\n- return newArray;\n- }\n-\n- public static long[] removeAt(long[] array, int index) {\n- long[] newArray = new long[array.length - 1];\n- System.arraycopy(array, 0, newArray, 0, index);\n- System.arraycopy(array, index + 1, newArray, index, array.length - index - 1);\n- return newArray;\n- }\n-\n- public static <T> T[] remove(T[] array, T value) {\n- int index = indexOf(array, value);\n- return (index != -1 ? removeAt(array, index) : array);\n- }\n-\n- public static long[] remove(long[] array, long value) {\n- int index = indexOf(array, value);\n- return (index != -1 ? removeAt(array, index) : array);\n- }\n-\n- public static long[] removeAll(long[] array, long[] valuesToRemove) {\n- long[] sortedValues = copy(valuesToRemove);\n- Arrays.sort(sortedValues);\n- long[] filtered = new long[array.length];\n- int cursor = 0;\n- for (long l : array) {\n- if (Arrays.binarySearch(sortedValues, l) < 0) {\n- filtered[cursor++] = l;\n- }\n- }\n- return Arrays.copyOf(filtered, cursor);\n- }\n-\n- public static <T> T[] set(T[] array, int index, T value) {\n- T[] newArray = Arrays.copyOf(array, array.length);\n- newArray[index] = value;\n- return newArray;\n- }\n-\n- public static long[] set(long[] array, int index, long value) {\n- long[] newArray = Arrays.copyOf(array, array.length);\n- newArray[index] = value;\n- return newArray;\n- }\n-\n- public static <T> T[] add(T[] array, T value) {\n- T[] newArray = Arrays.copyOf(array, array.length + 1);\n- newArray[newArray.length - 1] = value;\n- return newArray;\n- }\n-\n- public static long[] add(long[] array, long value) {\n- long[] newArray = Arrays.copyOf(array, array.length + 1);\n- newArray[newArray.length - 1] = value;\n- return newArray;\n- }\n-\n- public static long[] add(long[] array, long[] values) {\n- long[] newArray = Arrays.copyOf(array, array.length + values.length);\n- System.arraycopy(values, 0, newArray, array.length, values.length);\n- return newArray;\n- }\n-\n- public static <T> T[] copy(T[] array) {\n- return Arrays.copyOf(array, array.length);\n- }\n-\n- public static long[] copy(long[] array) {\n- return Arrays.copyOf(array, array.length);\n- }\n-\n- public static <T> T[] addIfAbsent(T[] array, T value) {\n- return (indexOf(array, value) == -1 ? add(array, value) : array);\n- }\n-\n- public static <T> int indexOf(T[] array, T value) {\n- for (int i = 0; i < array.length; i++) {\n- if (Objects.equals(array[i], value)) {\n- return i;\n- }\n- }\n- return -1;\n- }\n-\n- public static int indexOf(long[] array, long value) {\n- for (int i = 0; i < array.length; i++) {\n- if (array[i] == value) {\n- return i;\n- }\n- }\n- return -1;\n- }\n-\n- public static <T> T[] concat(T[] array1, T[] array2) {\n- T[] newArray = Arrays.copyOf(array1, array1.length + array2.length);\n- System.arraycopy(array2, 0, newArray, array1.length, array2.length);\n- return newArray;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/util/pmap/COWArrays.kt", "diff": "+package org.modelix.model.util.pmap\n+\n+import java.util.*\n+\n+object COWArrays {\n+ fun <T> insert(array: Array<T>, index: Int, element: T): Array<T> {\n+ val newArray = java.lang.reflect.Array.newInstance(array.javaClass.componentType, array.size + 1) as Array<T>\n+ System.arraycopy(array, 0, newArray, 0, index)\n+ newArray[index] = element\n+ System.arraycopy(array, index, newArray, index + 1, array.size - index)\n+ return newArray\n+ }\n+\n+ fun insert(array: LongArray, index: Int, element: Long): LongArray {\n+ val newArray = LongArray(array.size + 1)\n+ System.arraycopy(array, 0, newArray, 0, index)\n+ newArray[index] = element\n+ System.arraycopy(array, index, newArray, index + 1, array.size - index)\n+ return newArray\n+ }\n+\n+ fun insert(array: LongArray, index: Int, elements: LongArray): LongArray {\n+ val newArray = LongArray(array.size + elements.size)\n+ System.arraycopy(array, 0, newArray, 0, index)\n+ System.arraycopy(elements, 0, newArray, index, elements.size)\n+ System.arraycopy(array, index, newArray, index + elements.size, array.size - index)\n+ return newArray\n+ }\n+\n+ fun <T> removeAt(array: Array<T>, index: Int): Array<T> {\n+ val newArray = java.lang.reflect.Array.newInstance(array.javaClass.componentType, array.size - 1) as Array<T>\n+ System.arraycopy(array, 0, newArray, 0, index)\n+ System.arraycopy(array, index + 1, newArray, index, array.size - index - 1)\n+ return newArray\n+ }\n+\n+ fun removeAt(array: LongArray, index: Int): LongArray {\n+ val newArray = LongArray(array.size - 1)\n+ System.arraycopy(array, 0, newArray, 0, index)\n+ System.arraycopy(array, index + 1, newArray, index, array.size - index - 1)\n+ return newArray\n+ }\n+\n+ fun <T> remove(array: Array<T>, value: T): Array<T> {\n+ val index = indexOf(array, value)\n+ return if (index != -1) removeAt(array, index) else array\n+ }\n+\n+ @JvmStatic\n+ fun remove(array: LongArray, value: Long): LongArray {\n+ val index = indexOf(array, value)\n+ return if (index != -1) removeAt(array, index) else array\n+ }\n+\n+ fun removeAll(array: LongArray, valuesToRemove: LongArray): LongArray {\n+ val sortedValues = copy(valuesToRemove)\n+ Arrays.sort(sortedValues)\n+ val filtered = LongArray(array.size)\n+ var cursor = 0\n+ for (l in array) {\n+ if (Arrays.binarySearch(sortedValues, l) < 0) {\n+ filtered[cursor++] = l\n+ }\n+ }\n+ return Arrays.copyOf(filtered, cursor)\n+ }\n+\n+ operator fun <T> set(array: Array<T>, index: Int, value: T): Array<T> {\n+ val newArray = Arrays.copyOf(array, array.size)\n+ newArray[index] = value\n+ return newArray\n+ }\n+\n+ operator fun set(array: LongArray, index: Int, value: Long): LongArray {\n+ val newArray = Arrays.copyOf(array, array.size)\n+ newArray[index] = value\n+ return newArray\n+ }\n+\n+ fun <T> add(array: Array<T>, value: T): Array<T> {\n+ val newArray = Arrays.copyOf(array, array.size + 1)\n+ newArray[newArray.size - 1] = value\n+ return newArray\n+ }\n+\n+ fun add(array: LongArray, value: Long): LongArray {\n+ val newArray = Arrays.copyOf(array, array.size + 1)\n+ newArray[newArray.size - 1] = value\n+ return newArray\n+ }\n+\n+ fun add(array: LongArray, values: LongArray): LongArray {\n+ val newArray = Arrays.copyOf(array, array.size + values.size)\n+ System.arraycopy(values, 0, newArray, array.size, values.size)\n+ return newArray\n+ }\n+\n+ fun <T> copy(array: Array<T>): Array<T> {\n+ return Arrays.copyOf(array, array.size)\n+ }\n+\n+ @JvmStatic\n+ fun copy(array: LongArray): LongArray {\n+ return Arrays.copyOf(array, array.size)\n+ }\n+\n+ fun <T> addIfAbsent(array: Array<T>, value: T): Array<T> {\n+ return if (indexOf(array, value) == -1) add(array, value) else array\n+ }\n+\n+ fun <T> indexOf(array: Array<T>, value: T): Int {\n+ for (i in array.indices) {\n+ if (array[i] == value) {\n+ return i\n+ }\n+ }\n+ return -1\n+ }\n+\n+ @JvmStatic\n+ fun indexOf(array: LongArray, value: Long): Int {\n+ for (i in array.indices) {\n+ if (array[i] == value) {\n+ return i\n+ }\n+ }\n+ return -1\n+ }\n+\n+ fun <T> concat(array1: Array<T>, array2: Array<T>): Array<T> {\n+ val newArray = Arrays.copyOf(array1, array1.size + array2.size)\n+ System.arraycopy(array2, 0, newArray, array1.size, array2.size)\n+ return newArray\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/util/pmap/LongKeyPMap.java", "new_path": "model-client/src/main/java/org/modelix/model/util/pmap/LongKeyPMap.java", "diff": "@@ -119,9 +119,9 @@ public class LongKeyPMap<V> {\nint physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex);\nif (isBitNotSet(bitmap, logicalIndex)) {\n- return new InternalNode<V>(bitmap | (1 << logicalIndex), COWArrays.insert(children, physicalIndex, child));\n+ return new InternalNode<V>(bitmap | (1 << logicalIndex), COWArrays.INSTANCE.insert(children, physicalIndex, child));\n} else {\n- return new InternalNode<V>(bitmap, COWArrays.set(children, physicalIndex, child));\n+ return new InternalNode<V>(bitmap, COWArrays.INSTANCE.set(children, physicalIndex, child));\n}\n}\n@@ -135,7 +135,7 @@ public class LongKeyPMap<V> {\nreturn null;\n}\n- INode<V>[] newChildren = COWArrays.removeAt(children, physicalIndex);\n+ INode<V>[] newChildren = COWArrays.INSTANCE.removeAt(children, physicalIndex);\nif (newChildren.length == 1 && newChildren[0] instanceof LeafNode) {\nreturn newChildren[0];\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/util/pmap/SmallPMap.java", "new_path": "model-client/src/main/java/org/modelix/model/util/pmap/SmallPMap.java", "diff": "@@ -108,23 +108,23 @@ public abstract class SmallPMap<K, V> implements CustomPMap<K, V> {\nreturn remove(key);\n}\n- int index = COWArrays.indexOf(keys, key);\n+ int index = COWArrays.INSTANCE.indexOf(keys, key);\nif (index != -1) {\nif (Objects.equals(value, values[index])) {\nreturn this;\n} else {\n- return create(keys, COWArrays.set(values, index, value));\n+ return create(keys, COWArrays.INSTANCE.set(values, index, value));\n}\n} else {\n- return create(COWArrays.add(keys, key), COWArrays.add(values, value));\n+ return create(COWArrays.INSTANCE.add(keys, key), COWArrays.INSTANCE.add(values, value));\n}\n}\n@Override\npublic SmallPMap<K, V> remove(K key) {\n- int index = COWArrays.indexOf(keys, key);\n+ int index = COWArrays.INSTANCE.indexOf(keys, key);\nif (index != -1) {\n- return create(COWArrays.removeAt(keys, index), COWArrays.removeAt(values, index));\n+ return create(COWArrays.INSTANCE.removeAt(keys, index), COWArrays.INSTANCE.removeAt(values, index));\n} else {\nreturn this;\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert COWArrays
426,504
01.08.2020 15:07:05
-7,200
4a4efdede70c85b039ce18f7e0427c85c4e42ed2
complete translation operations package
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/operations/OTBranch.java", "new_path": null, "diff": "-package org.modelix.model.operations;\n-\n-import org.modelix.model.api.IBranch;\n-import org.modelix.model.api.IBranchListener;\n-import org.modelix.model.api.IIdGenerator;\n-import org.modelix.model.api.IReadTransaction;\n-import org.modelix.model.api.ITransaction;\n-import org.modelix.model.api.ITree;\n-import org.modelix.model.api.IWriteTransaction;\n-import io.vavr.Tuple;\n-import io.vavr.Tuple2;\n-\n-import java.util.ArrayList;\n-import java.util.List;\n-import java.util.function.Supplier;\n-\n-public class OTBranch implements IBranch {\n-\n- private IBranch branch;\n- private IIdGenerator idGenerator;\n- private List<IAppliedOperation> operations = new ArrayList<>();\n- private final Object operationsLock = new Object();\n-\n- public OTBranch(IBranch branch, IIdGenerator idGenerator) {\n- this.branch = branch;\n- this.idGenerator = idGenerator;\n- }\n-\n- public void operationApplied(IAppliedOperation op) {\n- synchronized (operationsLock) {\n- operations.add(op);\n- }\n- }\n-\n- public List<IAppliedOperation> getNewOperations() {\n- synchronized (operationsLock) {\n- List<IAppliedOperation> result = operations;\n- operations = new ArrayList<IAppliedOperation>();\n- return result;\n- }\n- }\n-\n- public Tuple2<List<IAppliedOperation>, ITree> getOperationsAndTree() {\n- synchronized (operationsLock) {\n- return Tuple.of(getNewOperations(), computeRead(() -> getTransaction().getTree()));\n- }\n- }\n-\n- @Override\n- public void addListener(IBranchListener l) {\n- branch.addListener(l);\n- }\n- @Override\n- public void removeListener(IBranchListener l) {\n- branch.removeListener(l);\n- }\n- @Override\n- public boolean canRead() {\n- return branch.canRead();\n- }\n- @Override\n- public boolean canWrite() {\n- return branch.canWrite();\n- }\n- @Override\n- public <T> T computeRead(Supplier<T> computable) {\n- checkNotEDT();\n- return branch.computeRead(computable);\n- }\n- @Override\n- public <T> T computeWrite(Supplier<T> computable) {\n- checkNotEDT();\n- return branch.computeWrite(computable);\n- }\n- @Override\n- public IReadTransaction getReadTransaction() {\n- return branch.getReadTransaction();\n- }\n- @Override\n- public ITransaction getTransaction() {\n- return wrap(branch.getTransaction());\n- }\n- @Override\n- public IWriteTransaction getWriteTransaction() {\n- return wrap(branch.getWriteTransaction());\n- }\n- @Override\n- public void runRead(Runnable runnable) {\n- checkNotEDT();\n- branch.runRead(runnable);\n- }\n- @Override\n- public void runWrite(Runnable runnable) {\n- checkNotEDT();\n- branch.runWrite(runnable);\n- }\n-\n- public ITransaction wrap(ITransaction t) {\n- return (t instanceof IWriteTransaction ? wrap((IWriteTransaction) t) : t);\n- }\n-\n- public IWriteTransaction wrap(IWriteTransaction t) {\n- return new OTWriteTransaction(t, this, idGenerator);\n- }\n-\n- protected void checkNotEDT() {\n- }\n-\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/client/ReplicatedTree.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/client/ReplicatedTree.kt", "diff": "@@ -90,7 +90,7 @@ class ReplicatedTree(private val client: IModelClient, private val treeId: TreeI\nprotected fun createAndMergeLocalVersion() {\ncheckDisposed()\n- var opsAndTree: Tuple2<List<IAppliedOperation?>, ITree>\n+ var opsAndTree: Tuple2<List<IAppliedOperation>, ITree>\nvar localBase: CLVersion?\nval remoteBase = MutableObject<CLVersion?>()\nval newLocalVersion = MutableObject<CLVersion>()\n@@ -232,7 +232,7 @@ class ReplicatedTree(private val client: IModelClient, private val treeId: TreeI\nversion = initialVersion\nremoteVersion = initialVersion\nlocalBranch = PBranch(initialTree.value)\n- localOTBranch = OTBranch(localBranch, client.idGenerator)\n+ localOTBranch = OTBranch(localBranch, client.idGenerator!!)\nmerger = VersionMerger(client.storeCache!!, client.idGenerator!!)\nversionChangeDetector = object : VersionChangeDetector(client, treeId.getBranchKey(branchName)) {\noverride fun processVersionChange(oldVersionHash: String?, newVersionHash: String?) {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/operations/OTBranch.kt", "diff": "+package org.modelix.model.operations\n+\n+import io.vavr.Tuple\n+import io.vavr.Tuple2\n+import org.modelix.model.api.*\n+import java.util.*\n+import java.util.function.Supplier\n+\n+class OTBranch(private val branch: IBranch, private val idGenerator: IIdGenerator) : IBranch {\n+ private var operations: MutableList<IAppliedOperation> = ArrayList()\n+ private val operationsLock = Any()\n+ fun operationApplied(op: IAppliedOperation) {\n+ synchronized(operationsLock) { operations.add(op) }\n+ }\n+\n+ val newOperations: List<IAppliedOperation>\n+ get() {\n+ synchronized(operationsLock) {\n+ val result: List<IAppliedOperation> = operations\n+ operations = ArrayList()\n+ return result\n+ }\n+ }\n+\n+ val operationsAndTree: Tuple2<List<IAppliedOperation>, ITree>\n+ get() {\n+ synchronized(operationsLock) { return Tuple.of(newOperations, computeRead<ITree>(Supplier<ITree> { transaction.tree!! })) }\n+ }\n+\n+ override fun addListener(l: IBranchListener?) {\n+ branch.addListener(l)\n+ }\n+\n+ override fun removeListener(l: IBranchListener?) {\n+ branch.removeListener(l)\n+ }\n+\n+ override fun canRead(): Boolean {\n+ return branch.canRead()\n+ }\n+\n+ override fun canWrite(): Boolean {\n+ return branch.canWrite()\n+ }\n+\n+ override fun <T> computeRead(computable: Supplier<T>?): T {\n+ checkNotEDT()\n+ return branch.computeRead(computable)\n+ }\n+\n+ override fun <T> computeWrite(computable: Supplier<T>?): T {\n+ checkNotEDT()\n+ return branch.computeWrite(computable)\n+ }\n+\n+ override val readTransaction: IReadTransaction?\n+ get() = branch.readTransaction\n+\n+ override val transaction: ITransaction\n+ get() = wrap(branch.transaction)\n+\n+ override val writeTransaction: IWriteTransaction\n+ get() = wrap(branch.writeTransaction)\n+\n+ override fun runRead(runnable: Runnable?) {\n+ checkNotEDT()\n+ branch.runRead(runnable)\n+ }\n+\n+ override fun runWrite(runnable: Runnable?) {\n+ checkNotEDT()\n+ branch.runWrite(runnable)\n+ }\n+\n+ fun wrap(t: ITransaction?): ITransaction {\n+ return if (t is IWriteTransaction) wrap(t as IWriteTransaction?) else t!!\n+ }\n+\n+ fun wrap(t: IWriteTransaction?): IWriteTransaction {\n+ return OTWriteTransaction(t!!, this, idGenerator)\n+ }\n+\n+ protected fun checkNotEDT() {}\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "@@ -18,7 +18,7 @@ class OTWriteTransaction(private val transaction: IWriteTransaction, private val\nLOG.debug(\"apply: $op\")\n}\nval appliedOp = op.apply(transaction)\n- otBranch.operationApplied(appliedOp)\n+ otBranch.operationApplied(appliedOp!!)\n}\noverride fun moveChild(newParentId: Long, newRole: String?, newIndex: Int, childId: Long) {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
complete translation operations package
426,504
01.08.2020 15:21:40
-7,200
575175fa4777351d7f26a294ea038d7f113b2820
convert LongKeyPMap
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/util/pmap/LongKeyPMap.java", "new_path": null, "diff": "-package org.modelix.model.util.pmap;\n-\n-import org.apache.commons.lang3.mutable.MutableObject;\n-import org.jetbrains.annotations.Nullable;\n-\n-import java.util.function.BiPredicate;\n-\n-public class LongKeyPMap<V> {\n-\n- private static final int BITS_PER_LEVEL = 5;\n- private static final int ENTRIES_PER_LEVEL = 1 << BITS_PER_LEVEL;\n- private static final int LEVEL_MASK = 0xffffffff >>> (32 - BITS_PER_LEVEL);\n- private static final int MAX_BITS = 64;\n- private static final int MAX_SHIFT = MAX_BITS - BITS_PER_LEVEL;\n-\n- private final INode<V> root;\n-\n- public LongKeyPMap() {\n- this(null);\n- }\n-\n- protected LongKeyPMap(INode<V> root) {\n- this.root = (root == null ? new EmptyNode<V>() : root);\n- }\n-\n- public V get(long key) {\n- return root.get(key, 0);\n- }\n-\n- public LongKeyPMap<V> put(long key, V value) {\n- return new LongKeyPMap(this.root.put(key, value, 0));\n- }\n-\n- public LongKeyPMap<V> remove(long key) {\n- return new LongKeyPMap(root.remove(key, 0));\n- }\n-\n- public void visitEntries(BiPredicate<Long, V> visitor) {\n- root.visitEntries(visitor);\n- }\n-\n- public void visitChanges(LongKeyPMap<V> oldMap, IChangeVisitor<V> visitor) {\n- root.visitChanges(oldMap.root, visitor);\n- }\n-\n- public interface INode<V> {\n- INode put(long key, @Nullable V value, int shift);\n- INode remove(long key, int shift);\n- V get(long key, int shift);\n- boolean visitEntries(BiPredicate<Long, V> visitor);\n- void visitChanges(INode<V> oldNode, IChangeVisitor<V> visitor);\n- }\n-\n- public interface IChangeVisitor<V> {\n- void entryAdded(long key, V value);\n- void entryRemoved(long key, V value);\n- void entryChanged(long key, V oldValue, V newValue);\n- }\n-\n- public static class InternalNode<V> implements INode<V> {\n- private static INode[] EMPTY_CHILDREN = new INode[0];\n- public static final InternalNode EMPTY = new InternalNode(0, EMPTY_CHILDREN);\n- public static <T> InternalNode<T> empty() {\n- return EMPTY;\n- }\n-\n- private final int bitmap;\n- private final INode<V>[] children;\n-\n- public InternalNode(int bitmap, INode<V>[] children) {\n- this.bitmap = bitmap;\n- this.children = children;\n- }\n-\n- @Override\n- public INode<V> put(long key, V value, int shift) {\n- int childIndex = (int) ((key >>> shift) & LEVEL_MASK);\n- INode<V> child = getChild(childIndex);\n- if (child == null) {\n- return setChild(childIndex, LeafNode.create(key, value));\n- } else {\n- return setChild(childIndex, child.put(key, value, shift + BITS_PER_LEVEL));\n- }\n- }\n-\n- @Override\n- public INode<V> remove(long key, int shift) {\n- int childIndex = (int) ((key >>> shift) & LEVEL_MASK);\n- INode<V> child = getChild(childIndex);\n- if (child == null) {\n- return this;\n- } else {\n- return setChild(childIndex, child.remove(key, shift + BITS_PER_LEVEL));\n- }\n- }\n-\n- @Override\n- public V get(long key, int shift) {\n- int childIndex = (int) ((key >>> shift) & LEVEL_MASK);\n- INode<V> child = getChild(childIndex);\n- if (child == null) {\n- return null;\n- }\n- return child.get(key, shift + BITS_PER_LEVEL);\n- }\n-\n- public INode<V> getChild(int logicalIndex) {\n- if (isBitNotSet(bitmap, logicalIndex)) {\n- return null;\n- }\n- int physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex);\n- return children[physicalIndex];\n- }\n-\n- public INode<V> setChild(int logicalIndex, INode child) {\n- if (child == null) {\n- return deleteChild(logicalIndex);\n- }\n-\n- int physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex);\n- if (isBitNotSet(bitmap, logicalIndex)) {\n- return new InternalNode<V>(bitmap | (1 << logicalIndex), COWArrays.INSTANCE.insert(children, physicalIndex, child));\n- } else {\n- return new InternalNode<V>(bitmap, COWArrays.INSTANCE.set(children, physicalIndex, child));\n- }\n- }\n-\n- public INode<V> deleteChild(int logicalIndex) {\n- if (isBitNotSet(bitmap, logicalIndex)) {\n- return this;\n- }\n- int physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex);\n- int newBitmap = bitmap & (~(1 << logicalIndex));\n- if (newBitmap == 0) {\n- return null;\n- }\n-\n- INode<V>[] newChildren = COWArrays.INSTANCE.removeAt(children, physicalIndex);\n- if (newChildren.length == 1 && newChildren[0] instanceof LeafNode) {\n- return newChildren[0];\n- }\n- return new InternalNode<V>(newBitmap, newChildren);\n- }\n-\n- @Override\n- public boolean visitEntries(BiPredicate<Long, V> visitor) {\n- for (INode<V> child : children) {\n- boolean continueVisit = child.visitEntries(visitor);\n- if (!(continueVisit)) {\n- return false;\n- }\n- }\n- return true;\n- }\n-\n- @Override\n- public void visitChanges(final INode<V> oldNode, final IChangeVisitor<V> visitor) {\n- if (oldNode == this) {\n- return;\n- }\n-\n- if (oldNode instanceof InternalNode) {\n- if (bitmap == ((InternalNode) oldNode).bitmap) {\n- for (int i = 0; i < children.length; i++) {\n- children[i].visitChanges(((InternalNode<V>) oldNode).children[i], visitor);\n- }\n- } else {\n- for (int logicalIndex = 0; logicalIndex < ENTRIES_PER_LEVEL; logicalIndex++) {\n- INode<V> child = getChild(logicalIndex);\n- INode<V> oldChild = ((InternalNode<V>) oldNode).getChild(logicalIndex);\n-\n- if (child == null) {\n- if (oldChild == null) {\n- // no change\n- } else {\n- oldChild.visitEntries((key, value) -> {\n- visitor.entryRemoved(key, value);\n- return true;\n- });\n- }\n- } else {\n- if (oldChild == null) {\n- child.visitEntries((key, value) -> {\n- visitor.entryAdded(key, value);\n- return true;\n- });\n- } else {\n- child.visitChanges(oldChild, visitor);\n- }\n- }\n- }\n- }\n- } else if (oldNode instanceof LeafNode) {\n- visitEntries((k, v) -> {\n- if (k == ((LeafNode<V>) oldNode).key) {\n- if (v != ((LeafNode<V>) oldNode).value) {\n- visitor.entryChanged(k, ((LeafNode<V>) oldNode).value, v);\n- }\n- } else {\n- visitor.entryAdded(k, v);\n- }\n- return true;\n- });\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + oldNode.getClass().getName());\n- }\n- }\n- }\n-\n- public static class LeafNode<V> implements INode<V> {\n-\n- public static <V> LeafNode<V> create(long key, V value) {\n- return (value == null ? null : new LeafNode<V>(key, value));\n- }\n-\n- private final long key;\n- private final V value;\n-\n- public LeafNode(long key, V value) {\n- this.key = key;\n- this.value = value;\n- }\n-\n- @Override\n- public INode put(long key, V value, int shift) {\n- if (key == this.key) {\n- if (value == this.value) {\n- return this;\n- } else {\n- return create(key, value);\n- }\n- } else {\n- if (shift > MAX_SHIFT) {\n- throw new RuntimeException(shift + \" > \" + MAX_SHIFT);\n- }\n- INode<V> result = InternalNode.<V>empty();\n- result = result.put(this.key, this.value, shift);\n- if (result == null) {\n- result = InternalNode.<V>empty();\n- }\n- result = result.put(key, value, shift);\n- return result;\n- }\n- }\n-\n- @Override\n- public INode remove(long key, int shift) {\n- if (key == this.key) {\n- return null;\n- } else {\n- return this;\n- }\n- }\n-\n- @Override\n- public V get(long key, int shift) {\n- return (this.key == key ? this.value : null);\n- }\n-\n- @Override\n- public boolean visitEntries(BiPredicate<Long, V> visitor) {\n- return visitor.test(key, value);\n- }\n-\n- @Override\n- public void visitChanges(INode<V> oldNode, final IChangeVisitor<V> visitor) {\n- if (oldNode == this) {\n- return;\n- }\n-\n- final MutableObject<V> oldValue = new MutableObject<>();\n- oldNode.visitEntries((k, v) -> {\n- if (k == LeafNode.this.key) {\n- oldValue.setValue(v);\n- } else {\n- visitor.entryRemoved(k, v);\n- }\n- return true;\n- });\n-\n- if (oldValue.getValue() == null) {\n- visitor.entryAdded(key, value);\n- } else if (oldValue.getValue() != this.value) {\n- visitor.entryChanged(this.key, oldValue.getValue(), this.value);\n- }\n- }\n- }\n-\n- public static class EmptyNode<V> implements INode<V> {\n-\n- public EmptyNode() {\n- }\n-\n- @Override\n- public INode put(long key, @Nullable V value, int shift) {\n- return LeafNode.create(key, value);\n- }\n-\n- @Override\n- public V get(long key, int shift) {\n- return null;\n- }\n-\n- @Override\n- public INode remove(long key, int shift) {\n- return this;\n- }\n-\n- @Override\n- public boolean visitEntries(BiPredicate<Long, V> visitor) {\n- return true;\n- }\n-\n- @Override\n- public void visitChanges(INode<V> oldNode, final IChangeVisitor<V> visitor) {\n- if (oldNode == this) {\n- return;\n- }\n-\n- oldNode.visitEntries((k, v) -> {\n- visitor.entryRemoved(k, v);\n- return true;\n- });\n- }\n- }\n-\n- public static int logicalToPhysicalIndex(int bitmap, int logicalIndex) {\n- return Integer.bitCount(bitmap & ((1 << logicalIndex) - 1));\n- }\n-\n- public static boolean isBitNotSet(int bitmap, int logicalIndex) {\n- return (bitmap & (1 << logicalIndex)) == 0;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/util/pmap/LongKeyPMap.kt", "diff": "+package org.modelix.model.util.pmap\n+\n+import org.apache.commons.lang3.mutable.MutableObject\n+import org.modelix.model.util.pmap.COWArrays.insert\n+import org.modelix.model.util.pmap.COWArrays.removeAt\n+import org.modelix.model.util.pmap.COWArrays.set\n+import java.util.function.BiPredicate\n+\n+class LongKeyPMap<V> protected constructor(root: INode<V?>?) {\n+ private val root: INode<V?>\n+\n+ constructor() : this(null) {}\n+\n+ operator fun get(key: Long): V {\n+ return root[key, 0]!!\n+ }\n+\n+ fun put(key: Long, value: V): LongKeyPMap<V?> {\n+ return LongKeyPMap<V?>(this.root.put(key, value, 0) as INode<V?>)\n+ }\n+\n+ fun remove(key: Long): LongKeyPMap<V?> {\n+ return LongKeyPMap<V?>(root.remove(key, 0) as INode<V?>)\n+ }\n+\n+ fun visitEntries(visitor: BiPredicate<Long, V?>?) {\n+ root.visitEntries(visitor!!)\n+ }\n+\n+ fun visitChanges(oldMap: LongKeyPMap<V>, visitor: IChangeVisitor<V?>?) {\n+ root.visitChanges(oldMap.root, visitor!!)\n+ }\n+\n+ interface INode<V> {\n+ fun put(key: Long, value: V?, shift: Int): INode<*>?\n+ fun remove(key: Long, shift: Int): INode<*>?\n+ operator fun get(key: Long, shift: Int): V\n+ fun visitEntries(visitor: BiPredicate<Long, V>): Boolean\n+ fun visitChanges(oldNode: INode<V>, visitor: IChangeVisitor<V>)\n+ }\n+\n+ interface IChangeVisitor<V> {\n+ fun entryAdded(key: Long, value: V)\n+ fun entryRemoved(key: Long, value: V)\n+ fun entryChanged(key: Long, oldValue: V, newValue: V)\n+ }\n+\n+ class InternalNode<V>(private val bitmap: Int, children: Array<INode<V?>>) : INode<V?> {\n+ private val children: Array<INode<V?>>\n+ override fun put(key: Long, value: V?, shift: Int): INode<V?>? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex)\n+ return if (child == null) {\n+ setChild(childIndex, LeafNode.create(key, value))\n+ } else {\n+ setChild(childIndex, child.put(key, value, shift + BITS_PER_LEVEL))\n+ }\n+ }\n+\n+ override fun remove(key: Long, shift: Int): INode<V?>? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex)\n+ return if (child == null) {\n+ this as INode<V?>\n+ } else {\n+ setChild(childIndex, child.remove(key, shift + BITS_PER_LEVEL))\n+ }\n+ }\n+\n+ override fun get(key: Long, shift: Int): V? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex) ?: return null\n+ return child[key, shift + BITS_PER_LEVEL]\n+ }\n+\n+ fun getChild(logicalIndex: Int): INode<V?>? {\n+ if (isBitNotSet(bitmap, logicalIndex)) {\n+ return null\n+ }\n+ val physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex)\n+ return children[physicalIndex]\n+ }\n+\n+ fun setChild(logicalIndex: Int, child: INode<*>?): INode<V?>? {\n+ if (child == null) {\n+ return deleteChild(logicalIndex)\n+ }\n+ val physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex)\n+ return if (isBitNotSet(bitmap, logicalIndex)) {\n+ val bm : Int = bitmap or (1 shl logicalIndex)\n+ val resultingArray : Array<INode<V?>> = insert<INode<V?>>(children as Array<INode<V?>>, physicalIndex, child as INode<V?>) as Array<INode<V?>>\n+ InternalNode(bm, resultingArray)\n+ } else {\n+ InternalNode(bitmap, set<INode<V?>>(children, physicalIndex, child as INode<V?>))\n+ }\n+ }\n+\n+ fun deleteChild(logicalIndex: Int): INode<V?>? {\n+ if (isBitNotSet(bitmap, logicalIndex)) {\n+ return this\n+ }\n+ val physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex)\n+ val newBitmap = bitmap and (1 shl logicalIndex).inv()\n+ if (newBitmap == 0) {\n+ return null\n+ }\n+ val newChildren: Array<INode<V?>> = removeAt(children, physicalIndex)\n+ return if (newChildren.size == 1 && newChildren[0] is LeafNode<*>) {\n+ newChildren[0]\n+ } else InternalNode(newBitmap, newChildren)\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, V?>): Boolean {\n+ for (child in children) {\n+ val continueVisit = child.visitEntries(visitor)\n+ if (!continueVisit) {\n+ return false\n+ }\n+ }\n+ return true\n+ }\n+\n+ override fun visitChanges(oldNode: INode<V?>, visitor: IChangeVisitor<V?>) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ if (oldNode is InternalNode<*>) {\n+ if (bitmap == (oldNode as InternalNode<*>).bitmap) {\n+ for (i in children.indices) {\n+ children[i].visitChanges((oldNode as InternalNode<V?>).children[i], visitor)\n+ }\n+ } else {\n+ for (logicalIndex in 0 until ENTRIES_PER_LEVEL) {\n+ val child = getChild(logicalIndex)\n+ val oldChild = (oldNode as InternalNode<V?>).getChild(logicalIndex)\n+ if (child == null) {\n+ if (oldChild == null) {\n+ // no change\n+ } else {\n+ oldChild.visitEntries(BiPredicate { key: Long?, value: V? ->\n+ visitor.entryRemoved(key!!, value)\n+ true\n+ })\n+ }\n+ } else {\n+ if (oldChild == null) {\n+ child.visitEntries(BiPredicate { key: Long?, value: V? ->\n+ visitor.entryAdded(key!!, value)\n+ true\n+ })\n+ } else {\n+ child.visitChanges(oldChild, visitor)\n+ }\n+ }\n+ }\n+ }\n+ } else if (oldNode is LeafNode<*>) {\n+ visitEntries(BiPredicate { k: Long, v: V? ->\n+ if (k == (oldNode as LeafNode<V?>).key) {\n+ if (v !== oldNode.value) {\n+ visitor.entryChanged(k, oldNode.value, v)\n+ }\n+ } else {\n+ visitor.entryAdded(k, v)\n+ }\n+ true\n+ })\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + oldNode.javaClass.name)\n+ }\n+ }\n+\n+ companion object {\n+ private val EMPTY_CHILDREN: Array<INode<*>?> = arrayOfNulls(0)\n+ val EMPTY: InternalNode<*> = InternalNode<Any?>(0, EMPTY_CHILDREN as Array<INode<Any?>>)\n+ fun <T> empty(): InternalNode<T> {\n+ return EMPTY as InternalNode<T>\n+ }\n+ }\n+\n+ init {\n+ this.children = children\n+ }\n+ }\n+\n+ class LeafNode<V>(val key: Long, val value: V) : INode<V?> {\n+ override fun put(key: Long, value: V?, shift: Int): INode<*>? {\n+ return if (key == this.key) {\n+ if (value === this.value) {\n+ this\n+ } else {\n+ create(key, value)\n+ }\n+ } else {\n+ if (shift > MAX_SHIFT) {\n+ throw RuntimeException(\"$shift > $MAX_SHIFT\")\n+ }\n+ var result: INode<V?>? = InternalNode.empty<V?>()\n+ result = result!!.put(this.key, this.value, shift) as INode<V?>\n+ if (result == null) {\n+ result = InternalNode.empty<V?>()\n+ }\n+ result = result.put(key, value, shift) as INode<V?>\n+ result\n+ }\n+ }\n+\n+ override fun remove(key: Long, shift: Int): INode<*>? {\n+ return if (key == this.key) {\n+ null\n+ } else {\n+ this\n+ }\n+ }\n+\n+ override fun get(key: Long, shift: Int): V? {\n+ return if (this.key == key) value else null\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, V?>): Boolean {\n+ return visitor.test(key, value)\n+ }\n+\n+ override fun visitChanges(oldNode: INode<V?>, visitor: IChangeVisitor<V?>) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ val oldValue = MutableObject<V?>()\n+ oldNode.visitEntries(BiPredicate { k: Long, v: V? ->\n+ if (k == key) {\n+ oldValue.setValue(v)\n+ } else {\n+ visitor.entryRemoved(k, v)\n+ }\n+ true\n+ })\n+ if (oldValue.value == null) {\n+ visitor.entryAdded(key, value)\n+ } else if (oldValue.value !== value) {\n+ visitor.entryChanged(key, oldValue.value, value)\n+ }\n+ }\n+\n+ companion object {\n+ fun <V> create(key: Long, value: V?): LeafNode<V>? {\n+ return value?.let { LeafNode(key, it) }\n+ }\n+ }\n+\n+ }\n+\n+ class EmptyNode<V> : INode<V?> {\n+ override fun put(key: Long, value: V?, shift: Int): INode<*>? {\n+ return LeafNode.create(key, value)\n+ }\n+\n+ override fun get(key: Long, shift: Int): V? {\n+ return null\n+ }\n+\n+ override fun remove(key: Long, shift: Int): INode<*> {\n+ return this\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, V?>): Boolean {\n+ return true\n+ }\n+\n+ override fun visitChanges(oldNode: INode<V?>, visitor: IChangeVisitor<V?>) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ oldNode.visitEntries(BiPredicate { k: Long?, v: V? ->\n+ visitor.entryRemoved(k!!, v)\n+ true\n+ })\n+ }\n+ }\n+\n+ companion object {\n+ private const val BITS_PER_LEVEL = 5\n+ private const val ENTRIES_PER_LEVEL = 1 shl BITS_PER_LEVEL\n+ private const val LEVEL_MASK = -0x1 ushr 32 - BITS_PER_LEVEL\n+ private const val MAX_BITS = 64\n+ private const val MAX_SHIFT = MAX_BITS - BITS_PER_LEVEL\n+ fun logicalToPhysicalIndex(bitmap: Int, logicalIndex: Int): Int {\n+ return Integer.bitCount(bitmap and (1 shl logicalIndex) - 1)\n+ }\n+\n+ fun isBitNotSet(bitmap: Int, logicalIndex: Int): Boolean {\n+ return bitmap and (1 shl logicalIndex) == 0\n+ }\n+ }\n+\n+ init {\n+ this.root = root ?: EmptyNode<V?>()\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert LongKeyPMap
426,504
01.08.2020 15:31:37
-7,200
9b124c58660be93aecfd2566bb8d70c5f9006a98
convert IDeserializingKeyValueStore
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.kt", "diff": "@@ -4,6 +4,7 @@ import io.vavr.Tuple\nimport io.vavr.Tuple3\nimport org.apache.commons.lang3.mutable.MutableInt\nimport java.util.Arrays\n+import java.util.function.BiFunction\nimport java.util.function.Consumer\nimport java.util.function.Function\nimport java.util.stream.Collectors\n@@ -18,11 +19,11 @@ class BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\nprivate var queue: MutableList<Tuple3<String, Function<String, *>, Consumer<Any?>>> = ArrayList()\nprivate var processing = false\nprotected fun executeBulkQuery(keys: Iterable<String>, deserializers: Map<String, Function<String, *>>): Map<String, Any> {\n- val values = store.getAll(keys) { key: String?, serialized: String? -> deserializers[key]!!.apply(serialized!!) }\n+ val values = store.getAll(keys, BiFunction<String?, String?, Any> { key: String?, serialized: String? -> deserializers[key]!!.apply(serialized!!) })\nval result: MutableMap<String, Any> = HashMap()\nrun {\nval key_it = keys.iterator()\n- val value_it: Iterator<Any> = values.iterator()\n+ val value_it: Iterator<Any> = values!!.iterator()\nvar key_var: String\nvar value_var: Any\nwhile (key_it.hasNext() && value_it.hasNext()) {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLVersion.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLVersion.kt", "diff": "@@ -4,6 +4,7 @@ import org.modelix.model.operations.IOperation\nimport org.modelix.model.persistent.CPOperationsList\nimport org.modelix.model.persistent.CPVersion\nimport java.util.Arrays\n+import java.util.function.Function\nclass CLVersion {\nprivate var store: IDeserializingKeyValueStore\n@@ -22,7 +23,7 @@ class CLVersion {\nIDeserializingKeyValueStore_extensions.put(store, data, data!!.serialize())\n}\n- constructor(hash: String?, store: IDeserializingKeyValueStore) : this(store.get<CPVersion>(hash) { input: String? -> CPVersion.deserialize(input) }, store) {}\n+ constructor(hash: String?, store: IDeserializingKeyValueStore) : this(store.get<CPVersion>(hash, Function { input: String? -> CPVersion.deserialize(input) }), store) {}\nconstructor(data: CPVersion, store: IDeserializingKeyValueStore) {\nif (data == null) {\nthrow NullPointerException(\"data is null\")\n@@ -57,14 +58,14 @@ class CLVersion {\nif (data!!.previousVersion == null) {\nreturn null\n}\n- val previousVersion = store.get(data!!.previousVersion) { input: String? -> CPVersion.deserialize(input) }\n+ val previousVersion = store.get(data!!.previousVersion, Function { input: String? -> CPVersion.deserialize(input) })\n?: return null\nreturn CLVersion(previousVersion, store)\n}\nval operations: Iterable<IOperation>\nget() {\n- val ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash) { input: String? -> CPOperationsList.deserialize(input) }.operations\n+ val ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash, Function { input: String? -> CPOperationsList.deserialize(input) }).operations\nreturn Iterable { Arrays.stream(ops).iterator() }\n}\n@@ -78,7 +79,7 @@ class CLVersion {\ncompanion object {\n@JvmStatic\nfun loadFromHash(hash: String?, store: IDeserializingKeyValueStore): CLVersion? {\n- val data = store.get(hash) { input: String? -> CPVersion.deserialize(input) }\n+ val data = store.get(hash, Function { input: String? -> CPVersion.deserialize(input) })\nreturn data?.let { CLVersion(it, store) }\n}\n}\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/IDeserializingKeyValueStore.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.modelix.model.IKeyValueStore;\n-\n-import java.util.function.BiFunction;\n-import java.util.function.Function;\n-\n-public interface IDeserializingKeyValueStore {\n- IKeyValueStore getKeyValueStore();\n- <T> T get(String hash, Function<String, T> deserializer);\n- <T> Iterable<T> getAll(Iterable<String> hash, BiFunction<String, String, T> deserializer);\n- void put(String hash, Object deserialized, String serialized);\n- void prefetch(String hash);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/IDeserializingKeyValueStore.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.IKeyValueStore\n+import java.util.function.BiFunction\n+import java.util.function.Function\n+\n+interface IDeserializingKeyValueStore {\n+ val keyValueStore: IKeyValueStore?\n+ operator fun <T> get(hash: String?, deserializer: Function<String?, T>?): T\n+ fun <T> getAll(hash: Iterable<String?>?, deserializer: BiFunction<String?, String?, T>?): Iterable<T>?\n+ fun put(hash: String?, deserialized: Any?, serialized: String?)\n+ fun prefetch(hash: String?)\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert IDeserializingKeyValueStore
426,504
01.08.2020 15:32:33
-7,200
0c7e010e7c7232989a0bd86b274e733d58aa78e4
convert IDeserializingKeyValueStore_extensions
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "diff": "@@ -57,7 +57,7 @@ public class CLTree implements ITree {\nCLHamtNode idToHash = storeElement(root, new CLHamtInternal(store));\nthis.data = new CPTree(treeId.getId(), 1, HashUtil.sha256(idToHash.getData().serialize()));\n- IDeserializingKeyValueStore_extensions.put(store, this.data, this.data.serialize());\n+ IDeserializingKeyValueStore_extensions.INSTANCE.put(store, this.data, this.data.serialize());\n} else {\nthis.store = store;\nthis.data = data;\n@@ -70,7 +70,7 @@ public class CLTree implements ITree {\n}\nthis.store = store;\nthis.data = new CPTree(treeId, rootId, HashUtil.sha256(idToHash.getData().serialize()));\n- IDeserializingKeyValueStore_extensions.put(store, data, data.serialize());\n+ IDeserializingKeyValueStore_extensions.INSTANCE.put(store, data, data.serialize());\n}\npublic void prefetchAll() {\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/IDeserializingKeyValueStore_extensions.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.modelix.model.persistent.HashUtil;\n-import org.modelix.model.persistent.CPElement;\n-\n-public class IDeserializingKeyValueStore_extensions {\n- public IDeserializingKeyValueStore_extensions() {\n- }\n- public static void put(final IDeserializingKeyValueStore _this, Object deserialized, String serialized) {\n- _this.put(HashUtil.sha256(serialized), deserialized, serialized);\n- }\n- public static void put(final IDeserializingKeyValueStore _this, CPElement element) {\n- IDeserializingKeyValueStore_extensions.put(_this, element, element.serialize());\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/IDeserializingKeyValueStore_extensions.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.persistent.CPElement\n+import org.modelix.model.persistent.HashUtil\n+\n+object IDeserializingKeyValueStore_extensions {\n+ fun put(_this: IDeserializingKeyValueStore, deserialized: Any?, serialized: String?) {\n+ _this.put(HashUtil.sha256(serialized), deserialized, serialized)\n+ }\n+\n+ @JvmStatic\n+ fun put(_this: IDeserializingKeyValueStore, element: CPElement) {\n+ put(_this, element, element.serialize())\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert IDeserializingKeyValueStore_extensions
426,504
01.08.2020 15:34:03
-7,200
5e3cf8078ffe62bca13f2e7e432320fafad86e5e
convert NonBulkQuery
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.modelix.model.util.StreamUtils;\n-\n-import java.util.List;\n-import java.util.function.Consumer;\n-import java.util.function.Function;\n-import java.util.stream.Collectors;\n-\n-public class NonBulkQuery implements IBulkQuery {\n-\n- private IDeserializingKeyValueStore store;\n-\n- public NonBulkQuery(IDeserializingKeyValueStore store) {\n- this.store = store;\n- }\n-\n- @Override\n- public <I, O> IBulkQuery.Value<List<O>> map(Iterable<I> input, final Function<I, IBulkQuery.Value<O>> f) {\n- List<O> list = StreamUtils.INSTANCE.toStream(input).map(f).map(IBulkQuery.Value::execute).collect(Collectors.toList());\n- return new Value<List<O>>(list);\n- }\n-\n- @Override\n- public <T> IBulkQuery.Value<T> constant(T value) {\n- return new Value<T>(value);\n- }\n-\n- @Override\n- public <T> IBulkQuery.Value<T> get(String hash, Function<String, T> deserializer) {\n- return constant(store.get(hash, deserializer));\n- }\n-\n- public static class Value<T> implements IBulkQuery.Value<T> {\n- private final T value;\n- public Value(T value) {\n- this.value = value;\n- }\n- @Override\n- public T execute() {\n- return value;\n- }\n- @Override\n- public <R> IBulkQuery.Value<R> mapBulk(final Function<T, IBulkQuery.Value<R>> handler) {\n- return handler.apply(value);\n- }\n- @Override\n- public <R> IBulkQuery.Value<R> map(Function<T, R> handler) {\n- return new Value<R>(handler.apply(value));\n- }\n- @Override\n- public void onSuccess(Consumer<T> handler) {\n- handler.accept(value);\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.util.StreamUtils.toStream\n+import java.util.function.Consumer\n+import java.util.function.Function\n+import java.util.stream.Collectors\n+\n+class NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\n+ override fun <I, O> map(input: Iterable<I>, f: Function<I, IBulkQuery.Value<O>>): IBulkQuery.Value<List<O>> {\n+ val list = toStream(input).map(f).map(Function<IBulkQuery.Value<O>, O> { it.execute() }).collect(Collectors.toList())\n+ return Value(list)\n+ }\n+\n+ override fun <T> constant(value: T): IBulkQuery.Value<T> {\n+ return Value(value)\n+ }\n+\n+ override fun <T> get(hash: String, deserializer: Function<String?, T>): IBulkQuery.Value<T> {\n+ return constant(store.get(hash, deserializer))\n+ }\n+\n+ class Value<T>(private val value: T) : IBulkQuery.Value<T> {\n+ override fun execute(): T {\n+ return value\n+ }\n+\n+ override fun <R> mapBulk(handler: Function<T, IBulkQuery.Value<R>>): IBulkQuery.Value<R> {\n+ return handler.apply(value)\n+ }\n+\n+ override fun <R> map(handler: Function<T, R>): IBulkQuery.Value<R> {\n+ return Value(handler.apply(value))\n+ }\n+\n+ override fun onSuccess(handler: Consumer<T>) {\n+ handler.accept(value)\n+ }\n+\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert NonBulkQuery
426,504
01.08.2020 15:36:58
-7,200
0828b1b095d0d406777eddf7d8676cf7d25007ee
convert ObjectStoreCache
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLVersion.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLVersion.kt", "diff": "@@ -24,7 +24,7 @@ class CLVersion {\n}\nconstructor(hash: String?, store: IDeserializingKeyValueStore) : this(store.get<CPVersion>(hash, Function { input: String? -> CPVersion.deserialize(input) }), store) {}\n- constructor(data: CPVersion, store: IDeserializingKeyValueStore) {\n+ constructor(data: CPVersion?, store: IDeserializingKeyValueStore) {\nif (data == null) {\nthrow NullPointerException(\"data is null\")\n}\n@@ -65,7 +65,7 @@ class CLVersion {\nval operations: Iterable<IOperation>\nget() {\n- val ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash, Function { input: String? -> CPOperationsList.deserialize(input) }).operations\n+ val ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash, Function { input: String? -> CPOperationsList.deserialize(input) })!!.operations\nreturn Iterable { Arrays.stream(ops).iterator() }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/IDeserializingKeyValueStore.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/IDeserializingKeyValueStore.kt", "diff": "@@ -6,7 +6,7 @@ import java.util.function.Function\ninterface IDeserializingKeyValueStore {\nval keyValueStore: IKeyValueStore?\n- operator fun <T> get(hash: String?, deserializer: Function<String?, T>?): T\n+ operator fun <T> get(hash: String?, deserializer: Function<String?, T>?): T?\nfun <T> getAll(hash: Iterable<String?>?, deserializer: BiFunction<String?, String?, T>?): Iterable<T>?\nfun put(hash: String?, deserialized: Any?, serialized: String?)\nfun prefetch(hash: String?)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.kt", "diff": "@@ -16,7 +16,7 @@ class NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery\n}\noverride fun <T> get(hash: String, deserializer: Function<String?, T>): IBulkQuery.Value<T> {\n- return constant(store.get(hash, deserializer))\n+ return constant(store.get(hash, deserializer)!!)\n}\nclass Value<T>(private val value: T) : IBulkQuery.Value<T> {\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/ObjectStoreCache.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.apache.commons.collections4.map.LRUMap;\n-import org.modelix.model.IKeyValueStore;\n-import org.modelix.model.util.StreamUtils;\n-\n-import java.util.ArrayList;\n-import java.util.Collections;\n-import java.util.HashMap;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.function.BiFunction;\n-import java.util.function.Function;\n-import java.util.stream.Collectors;\n-\n-public class ObjectStoreCache implements IDeserializingKeyValueStore {\n- private static final Object NULL = new Object();\n-\n- private IKeyValueStore store;\n- private final Map<String, Object> cache = Collections.synchronizedMap(new LRUMap<>(100000));\n-\n- public ObjectStoreCache(IKeyValueStore store1) {\n- store = store1;\n- }\n-\n- @Override\n- public IKeyValueStore getKeyValueStore() {\n- return store;\n- }\n-\n- @Override\n- public <T> Iterable<T> getAll(Iterable<String> hashes_, BiFunction<String, String, T> deserializer) {\n- List<String> hashes = StreamUtils.INSTANCE.toStream(hashes_).collect(Collectors.toList());\n- final Map<String, T> result = new HashMap<>();\n- List<String> nonCachedHashes = new ArrayList<>(hashes.size());\n-\n- for (String hash : hashes) {\n- T deserialized = (T) cache.get(hash);\n- if (deserialized == null) {\n- nonCachedHashes.add(hash);\n- } else {\n- result.put(hash, (deserialized == NULL ? null : deserialized));\n- }\n- }\n-\n- if (!nonCachedHashes.isEmpty()) {\n- for (Map.Entry<String, String> entry : store.getAll(nonCachedHashes).entrySet()) {\n- String hash = entry.getKey();\n- String serialized = entry.getValue();\n- if (serialized == null) {\n- result.put(hash, null);\n- } else {\n- T deserialized = deserializer.apply(hash, serialized);\n- cache.put(hash, (deserialized == null ? NULL : deserialized));\n- result.put(hash, deserialized);\n- }\n- }\n- }\n-\n- return hashes.stream().map(result::get)::iterator;\n- }\n-\n- public <T> T get(String hash, Function<String, T> deserializer) {\n- if (hash == null) {\n- return null;\n- }\n- T deserialized = (T) cache.get(hash);\n- if (deserialized == null) {\n- String serialized = store.get(hash);\n- if (serialized == null) {\n- return null;\n- }\n- deserialized = deserializer.apply(serialized);\n- cache.put(hash, (deserialized == null ? NULL : deserialized));\n- }\n- return (deserialized == NULL ? null : deserialized);\n- }\n-\n- public void put(String hash, Object deserialized, String serialized) {\n- store.put(hash, serialized);\n- cache.put(hash, (deserialized == null ? NULL : deserialized));\n- }\n-\n- public void clearCache() {\n- cache.clear();\n- }\n-\n- @Override\n- public void prefetch(String hash) {\n- store.prefetch(hash);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/ObjectStoreCache.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.apache.commons.collections4.map.LRUMap\n+import org.modelix.model.IKeyValueStore\n+import org.modelix.model.util.StreamUtils.toStream\n+import java.util.*\n+import java.util.function.BiFunction\n+import java.util.function.Function\n+import java.util.stream.Collectors\n+\n+class ObjectStoreCache(override val keyValueStore: IKeyValueStore) : IDeserializingKeyValueStore {\n+ private val cache = Collections.synchronizedMap(LRUMap<String?, Any>(100000))\n+\n+ override fun <T> getAll(hashes_: Iterable<String?>?, deserializer: BiFunction<String?, String?, T>?): Iterable<T>? {\n+ val hashes = toStream(hashes_!!).collect(Collectors.toList())\n+ val result: MutableMap<String?, T?> = HashMap()\n+ val nonCachedHashes: MutableList<String?> = ArrayList(hashes.size)\n+ for (hash in hashes) {\n+ val deserialized = cache[hash] as T?\n+ if (deserialized == null) {\n+ nonCachedHashes.add(hash)\n+ } else {\n+ result[hash] = if (deserialized === NULL) null else deserialized\n+ }\n+ }\n+ if (!nonCachedHashes.isEmpty()) {\n+ for ((hash, serialized) in keyValueStore.getAll(nonCachedHashes)!!) {\n+ if (serialized == null) {\n+ result[hash] = null\n+ } else {\n+ val deserialized: T? = deserializer!!.apply(hash, serialized)\n+ cache[hash] = deserialized ?: NULL\n+ result[hash] = deserialized\n+ }\n+ }\n+ }\n+ return Iterable<T> { hashes.stream().map { key: String? -> result[key] }.iterator() as Iterator<T> }\n+ }\n+\n+ override fun <T> get(hash: String?, deserializer: Function<String?, T>?): T? {\n+ if (hash == null) {\n+ return null\n+ }\n+ var deserialized = cache[hash] as T?\n+ if (deserialized == null) {\n+ val serialized = keyValueStore[hash] ?: return null\n+ deserialized = deserializer!!.apply(serialized)\n+ cache[hash] = deserialized ?: NULL\n+ }\n+ return if (deserialized === NULL) null else deserialized\n+ }\n+\n+ override fun put(hash: String?, deserialized: Any?, serialized: String?) {\n+ keyValueStore.put(hash, serialized)\n+ cache[hash] = deserialized ?: NULL\n+ }\n+\n+ fun clearCache() {\n+ cache.clear()\n+ }\n+\n+ override fun prefetch(hash: String?) {\n+ keyValueStore.prefetch(hash)\n+ }\n+\n+ companion object {\n+ private val NULL = Any()\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert ObjectStoreCache
426,504
01.08.2020 15:37:40
-7,200
0769b90cb4fb25fd255e79e7a1ad3e002de06f3f
convert TreeId
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/TreeId.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import java.util.UUID;\n-import org.jetbrains.annotations.NotNull;\n-\n-public class TreeId {\n- public static TreeId random() {\n- return new TreeId(UUID.randomUUID().toString());\n- }\n-\n- private final String id;\n-\n- public TreeId(@NotNull String id) {\n- this.id = id;\n- }\n-\n- public String getId() {\n- return this.id;\n- }\n-\n- @Deprecated\n- public String getMasterBranchKey() {\n- return getBranchKey(null);\n- }\n-\n- public String getBranchKey(String branchName) {\n- if ((branchName == null || branchName.length() == 0)) {\n- branchName = \"master\";\n- }\n- return \"branch_\" + id + \"_\" + branchName;\n- }\n-\n- @Override\n- public boolean equals(Object o) {\n- if (this == o) {\n- return true;\n- }\n- if (o == null || this.getClass() != o.getClass()) {\n- return false;\n- }\n-\n- TreeId that = (TreeId) o;\n- if ((id != null ? !(((Object) id).equals(that.id)) : that.id != null)) {\n- return false;\n- }\n-\n- return true;\n- }\n-\n- @Override\n- public int hashCode() {\n- int result = 0;\n- result = 31 * result + ((id != null ? String.valueOf(id).hashCode() : 0));\n- return result;\n- }\n-\n- @Override\n- public String toString() {\n- return id;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/TreeId.kt", "diff": "+package org.modelix.model.lazy\n+\n+import java.util.*\n+\n+class TreeId(val id: String) {\n+\n+ @get:Deprecated(\"\")\n+ val masterBranchKey: String\n+ get() = getBranchKey(null)\n+\n+ fun getBranchKey(branchName: String?): String {\n+ var branchName = branchName\n+ if (branchName == null || branchName.length == 0) {\n+ branchName = \"master\"\n+ }\n+ return \"branch_\" + id + \"_\" + branchName\n+ }\n+\n+ override fun equals(o: Any?): Boolean {\n+ if (this === o) {\n+ return true\n+ }\n+ if (o == null || this.javaClass != o.javaClass) {\n+ return false\n+ }\n+ val that = o as TreeId\n+ return if (if (id != null) id as Any != that.id else that.id != null) {\n+ false\n+ } else true\n+ }\n+\n+ override fun hashCode(): Int {\n+ var result = 0\n+ result = 31 * result + (id?.hashCode() ?: 0)\n+ return result\n+ }\n+\n+ override fun toString(): String {\n+ return id\n+ }\n+\n+ companion object {\n+ @JvmStatic\n+ fun random(): TreeId {\n+ return TreeId(UUID.randomUUID().toString())\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert TreeId