Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GraphDeployer
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coscine
backend
scripts
GraphDeployer
Commits
0c763c58
Commit
0c763c58
authored
Nov 9, 2023
by
Benedikt Heinrichs
Browse files
Options
Downloads
Patches
Plain Diff
New: Fast Deployment
parent
ca1f39ce
No related branches found
No related tags found
1 merge request
!16
New: Fast Deployment
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/GraphDeployer/HashUtil.cs
+18
-0
18 additions, 0 deletions
src/GraphDeployer/HashUtil.cs
src/GraphDeployer/Program.cs
+32
-18
32 additions, 18 deletions
src/GraphDeployer/Program.cs
with
50 additions
and
18 deletions
src/GraphDeployer/HashUtil.cs
0 → 100644
+
18
−
0
View file @
0c763c58
using
System.Security.Cryptography
;
namespace
Coscine.GraphDeployer
{
public
static
class
HashUtil
{
public
static
string
GetFileHash
(
string
path
)
{
using
(
SHA256
sha256
=
SHA256
.
Create
())
{
using
(
FileStream
fileStream
=
File
.
OpenRead
(
path
))
{
return
BitConverter
.
ToString
(
sha256
.
ComputeHash
(
fileStream
));
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/GraphDeployer/Program.cs
+
32
−
18
View file @
0c763c58
...
@@ -3,6 +3,7 @@ using Coscine.GraphDeployer.Logging;
...
@@ -3,6 +3,7 @@ using Coscine.GraphDeployer.Logging;
using
Coscine.Metadata
;
using
Coscine.Metadata
;
using
LibGit2Sharp
;
using
LibGit2Sharp
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Newtonsoft.Json
;
using
NLog.Config
;
using
NLog.Config
;
using
NLog.Extensions.Logging
;
using
NLog.Extensions.Logging
;
using
System.Diagnostics
;
using
System.Diagnostics
;
...
@@ -41,6 +42,10 @@ public class Program
...
@@ -41,6 +42,10 @@ public class Program
private
static
void
Run
()
private
static
void
Run
()
{
{
var
currentRun
=
new
Dictionary
<
string
,
string
>();
var
lastRun
=
JsonConvert
.
DeserializeObject
<
Dictionary
<
string
,
string
>>(
Configuration
.
GetString
(
"coscine/local/graph_deployer/last_run"
,
"{}"
));
lastRun
??=
new
Dictionary
<
string
,
string
>();
var
virtuosoServer
=
Configuration
.
GetString
(
"coscine/local/virtuoso/additional/url"
);
var
virtuosoServer
=
Configuration
.
GetString
(
"coscine/local/virtuoso/additional/url"
);
var
virtuosoHost
=
new
Uri
(
virtuosoServer
).
Host
;
var
virtuosoHost
=
new
Uri
(
virtuosoServer
).
Host
;
var
virtuosoUser
=
Configuration
.
GetString
(
"coscine/global/virtuoso_db_user"
);
var
virtuosoUser
=
Configuration
.
GetString
(
"coscine/global/virtuoso_db_user"
);
...
@@ -111,6 +116,15 @@ public class Program
...
@@ -111,6 +116,15 @@ public class Program
{
{
var
graph
=
kv
.
Value
.
Item1
;
var
graph
=
kv
.
Value
.
Item1
;
var
graphName
=
kv
.
Key
.
ToString
();
var
graphName
=
kv
.
Key
.
ToString
();
kv
.
Value
.
Item2
.
ForEach
((
path
)
=>
currentRun
.
TryAdd
(
graphName
+
path
,
HashUtil
.
GetFileHash
(
path
)));
var
changed
=
kv
.
Value
.
Item2
.
Any
((
path
)
=>
!
lastRun
.
ContainsKey
(
graphName
+
path
)
||
lastRun
[
graphName
+
path
]
!=
currentRun
[
graphName
+
path
]);
if
(!
changed
)
{
_logger
.
LogInformation
(
"Skipping {graphName}"
,
graphName
);
continue
;
}
var
currentGraph
=
Helpers
.
WrapRequest
(()
=>
_rdfStoreConnector
.
GetGraph
(
graphName
));
var
currentGraph
=
Helpers
.
WrapRequest
(()
=>
_rdfStoreConnector
.
GetGraph
(
graphName
));
...
@@ -121,8 +135,12 @@ public class Program
...
@@ -121,8 +135,12 @@ public class Program
var
graphWasChanged
=
graph
.
Triples
.
Count
!=
currentGraph
.
Triples
.
Count
var
graphWasChanged
=
graph
.
Triples
.
Count
!=
currentGraph
.
Triples
.
Count
||
projectedGraph
.
Except
(
projectedCurrentGraph
).
Any
();
||
projectedGraph
.
Except
(
projectedCurrentGraph
).
Any
();
if
(
graphWasChanged
)
if
(
!
graphWasChanged
)
{
{
_logger
.
LogInformation
(
"Skipping {graphName}"
,
graphName
);
continue
;
}
if
(!
currentGraph
.
IsEmpty
)
if
(!
currentGraph
.
IsEmpty
)
{
{
Helpers
.
WrapRequest
(()
=>
_rdfStoreConnector
.
ClearGraph
(
graphName
));
Helpers
.
WrapRequest
(()
=>
_rdfStoreConnector
.
ClearGraph
(
graphName
));
...
@@ -139,11 +157,6 @@ public class Program
...
@@ -139,11 +157,6 @@ public class Program
queries
.
Add
(
$"ld_dir('
{
fileInfo
.
DirectoryName
[
2
..].
Replace
(
"\\"
,
"/"
)}
', '
{
fileInfo
.
Name
}
', '
{
graphName
}
');"
);
queries
.
Add
(
$"ld_dir('
{
fileInfo
.
DirectoryName
[
2
..].
Replace
(
"\\"
,
"/"
)}
', '
{
fileInfo
.
Name
}
', '
{
graphName
}
');"
);
}
}
}
}
else
{
_logger
.
LogInformation
(
"Skipping {graphName}"
,
graphName
);
}
}
queries
.
Add
(
$"rdf_loader_run ();"
);
queries
.
Add
(
$"rdf_loader_run ();"
);
queries
.
Add
(
$"DELETE from DB.DBA.load_list where 1=1;"
);
queries
.
Add
(
$"DELETE from DB.DBA.load_list where 1=1;"
);
...
@@ -159,6 +172,7 @@ public class Program
...
@@ -159,6 +172,7 @@ public class Program
}
}
}
}
Configuration
.
Put
(
"coscine/local/graph_deployer/last_run"
,
JsonConvert
.
SerializeObject
(
currentRun
));
_logger
.
LogInformation
(
"Done"
);
_logger
.
LogInformation
(
"Done"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment