How do you set up a jobstore with Quartz.net. The tutorial they have on the site is not that of help for me.
In this page though there are steps
http://quartznet.sourceforge.net/tutorial/lesson_9.html
I am not able to get how to set this one
org.quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz
Thanks
Here's an adapted example of programmatic configuration from Quartz.NET's example 13:
NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "TestScheduler";
properties["quartz.scheduler.instanceId"] = "instance_one";
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
// if running MS SQL Server we need this
properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";
properties["quartz.dataSource.default.connectionString"] = "Server=(local);Database=quartz;Trusted_Connection=True;";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";
// First we must get a reference to a scheduler
ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler sched = sf.GetScheduler();
You can also achieve the same thing with properties file based approach (the .config file).
Update for Quartz 3.1 and later
You can also use fluent Microsoft DI registration API introduced in Quartz.NET 3.1 if you have Microsoft dependency injection in use. See configuration guide for details.
Related
I'm currently spending some time setting up a generic configuration using Jenkins AD-SecurityRealm (ActiveDirectorySecurityRealm) Plugin (v2.6) and stuck over a nasty issue: It seems that my approach to (auto) set up a valid AD-connection (following the corresponding documentation) is not working at all. Every time I'll re-init my Jenkins instance an incomplete config.xml will provide - the "bindName" property (XML-node) is always missing. This property is required by the ad-server I'll use and so I've to override the config manually to solve this issue.
I haven't the vaguest idea why this still happens.
my groovy code (excerpt)
String _domain = 'my-primary-ad-server-running.acme.org'
String _site = 'jenkins.acme.org'
String _bindName = 'ad-bind-user'
String _bindPassword = 'ad-bind-password-super-secret-123'
String _server = 'my-primary-ad-server-running.acme.org'
def hudsonActiveDirectoryRealm = new ActiveDirectorySecurityRealm(_domain, _site, _bindName, _bindPassword, _server)
def instance = Jenkins.getInstance()
instance.setSecurityRealm(hudsonActiveDirectoryRealm)
instance.save()
my config.xml result (excerpt)
<securityRealm class="hudson.plugins.active_directory.ActiveDirectorySecurityRealm" plugin="active-directory#2.6">
<domains>
<hudson.plugins.active__directory.ActiveDirectoryDomain>
<name>my-primary-ad-server-running.acme.org</name>
<servers>my-primary-ad-server-running.acme.org:3268</servers>
<bindPassword>{###-fancy-crypted-super-password-nobody-can-decrypt-anymore-###}</bindPassword>
</hudson.plugins.active__directory.ActiveDirectoryDomain>
</domains>
<startTls>true</startTls>
<groupLookupStrategy>AUTO</groupLookupStrategy>
<removeIrrelevantGroups>false</removeIrrelevantGroups>
<tlsConfiguration>TRUST_ALL_CERTIFICATES</tlsConfiguration>
</securityRealm>
my config.xml required (excerpt)
<securityRealm class="hudson.plugins.active_directory.ActiveDirectorySecurityRealm" plugin="active-directory#2.6">
<domains>
<hudson.plugins.active__directory.ActiveDirectoryDomain>
<name>my-primary-ad-server-running.acme.org</name>
<servers>my-primary-ad-server-running.acme.org:3268</servers>
<bindName>ad-bind-user</bindName>
<bindPassword>{###-fancy-crypted-super-password-nobody-can-decrypt-anymore-###}</bindPassword>
</hudson.plugins.active__directory.ActiveDirectoryDomain>
</domains>
<startTls>true</startTls>
<groupLookupStrategy>AUTO</groupLookupStrategy>
<removeIrrelevantGroups>false</removeIrrelevantGroups>
<tlsConfiguration>TRUST_ALL_CERTIFICATES</tlsConfiguration>
</securityRealm>
Thanks #kosta.
Following script also works using active-directory 2.10 and jenkins 2.150.1
This also include site information.
import hudson.plugins.active_directory.ActiveDirectoryDomain
import hudson.plugins.active_directory.ActiveDirectorySecurityRealm
import hudson.plugins.active_directory.GroupLookupStrategy
String _domain = 'dev.test.com'
String _site = 'HQ'
String _bindName = 'dev\jenkins'
String _bindPassword = 'test'
String _server = 'dev.test.com:2328'
def hudsonActiveDirectoryRealm = new ActiveDirectorySecurityRealm(_domain, _site, _bindName, _bindPassword, _server)
hudsonActiveDirectoryRealm.getDomains().each({
it.bindName = hudsonActiveDirectoryRealm.bindName
it.bindPassword = hudsonActiveDirectoryRealm.bindPassword
it.site = hudsonActiveDirectoryRealm.site
})
def instance = Jenkins.getInstance()
instance.setSecurityRealm(hudsonActiveDirectoryRealm)
instance.save()
Check this screenshot: Configure Global Security
If you look at the source code for ActiveDirectorySecurityRealm you will see that the bindName is marked as transient, thus it won't be persisted as part of the config XML.
The only solution to get the desired config.xml is to force the config.xml by providing a custom static one and not use the init script.
I was able to solve this issue by adding the following code at the end (Tested on 2.6 and 2.8). You also need to make sure that your credentials are valid because the plugin is doing an initial connectivity check https://issues.jenkins-ci.org/browse/JENKINS-48513
hudsonActiveDirectoryRealm.getDomains().each({
it.bindName = hudsonActiveDirectoryRealm.bindName
it.bindPassword = hudsonActiveDirectoryRealm.bindPassword
})
instance.setSecurityRealm(hudsonActiveDirectoryRealm)
instance.save()
I'm working with the Java cloud dataflow SDK and I'm working on some end to end tests.
#Test
public void testEndtoEnd() throws Exception {
TupleTag<Entity> tag1 = aTagFromElsewhere1;
TupleTag<Entity> tag2 = aTagFromElsewhere2;
TupleTagList tags = TupleTagList.of(tag1).and(tag2);
CoGbkResultSchema schema = new CoGbkResultSchema(tags);
JoinEntities myDoFn = new JoinEntities();
DoFnTester<KV<String, CoGbkResult>, Entity> fnTester = DoFnTester.of(myDoFn);
List<RawUnionValue> rawUnionValues = new ArrayList<RawUnionValue>();
Date validThruDate = new Date(System.currentTimeMillis() + 5000L);
rawUnionValues.add(new RawUnionValue(0, aValidEntity1)));
rawUnionValues.add(new RawUnionValue(1, aValidEntity2));
CoGbkResult result = new CoGbkResult(schema, rawUnionValues);
KV<String, CoGbkResult> aCoGbkPair = KV.of("Bleh", result);
Pipeline p = TestPipeline.create();
PCollection<KV<String, CoGbkResult>> input = p.apply(Create.of(aCoGbkPair))
.setCoder(KvCoder.of(StringUtf8Coder.of(), CoGbkResultCoder.of(UnionCoder, schema)));
PCollection<String> output = input.apply(new FormatEntitiesForTsv());
DataflowAssert.that(output).containsInAnyOrder(/**TODO: Create test data**/);
}
The problem I'm having is that within the setCoder, I am using a KvCoder.of() which requires a UnionCoder. I'm not sure how to get this UnionCoder and I've looked at the class for it and it isn't accessible.
How do I work around getting this? (Alternatively, if there is a better way to go about getting the input, I am all ears).
Thanks and cheers :)
Indeed, it's an oversight in the SDK - UnionCoder ought to be public, and it was made public in the Beam SDK some time ago. Your best option would be to either build your own version of the Dataflow SDK with this change, or wait for us to make the change in the github repo and wait for the next Maven release (I'll send a pull request and update this answer).
I'm trying to enable job persistence using the quartz plugin for grails (http://grails.org/plugin/quartz) but everytime I try to create a new job it cannot find the table. It looks like the plugin isn't creating the tables.
The database I'm using in mysql and my grails version is 2.3.11. I've tried to mirror the configuration used in this blog (http://blog.robinpercy.com/2012/11/06/grails-clustered-quartz-configs-by-environment/) but the tables aren't being created.
Here is my quartz configuration :
jdbcProps = {
scheduler.instanceName = "quartz"
scheduler.instanceId = "AUTO"
threadPool.class = "org.quartz.simpl.SimpleThreadPool"
threadPool.threadCount = 3
threadPool.threadPriority = 5
jobStore.misfireThreshold = 60000
jobStore.class = "org.quartz.impl.jdbcjobstore.JobStoreTX"
jobStore.driverDelegateClass = "org.quartz.impl.jdbcjobstore.MSSQLDelegate"
jobStore.useProperties = false
jobStore.tablePrefix = "qrtz_"
jobStore.isClustered = true
jobStore.clusterCheckinInterval = 5000
plugin.shutdownhook.class = "org.quartz.plugins.management.ShutdownHookPlugin"
plugin.shutdownhook.cleanShutdown = true
}
environments {
development {
quartz {
autoStartup = true
jdbcStore = true
waitForJobsToCompleteOnShutdown = true
props(jdbcProps)
}
}
}
Quartz can find the database specified in my datasource.groovy file but it cannot find the tables it needs.
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "root"
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://localhost:3306/appDatabase?autoReconnect=true"
properties {
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
Here is the exception
An error occurred while scanning for the next triggers to fire.
org.quartz.JobPersistenceException: Couldn't acquire next trigger: Table 'appDatabase.qrtz_TRIGGERS' doesn't exist [See nested exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'appDatabase.qrtz_TRIGGERS' doesn't exist
Am I missing something here? Do I need to manually create the tables or do I have some configuration error?
I haven't used this in a while, but I doubt it will create tables for you. The Quartz distro comes with DDL for over 20 databases in the docs/dbTables directory, so you would use the file for your database and version, and customize as needed before running them.
I did a conference talk a few years ago that included clustering Quartz and included an automated way to use Hibernate cfg.xml and hbm.xml files to create the tables. You can download the sample app and use that same approach - it'll still work with Hibernate 3 and should with Hibernate 4, but might require an update to the <!DOCTYPE ...> in the xml.
I'm new on MVC!
I want to run a process on my web app (not for bad purpose), this process can do something, for example it can write a text to a file .txt!
On my local PC, it work well but when I publish it on to host provider, it not work!
How I can do this?
This is my code:
string path = HttpContext.Current.Server.MapPath("~/App_Data/ModuleMaple/ModuleMaple.exe");
Process myproc = new Process();
myproc.StartInfo.FileName = path;
myproc.StartInfo.Arguments ="some argument"
myproc.StartInfo.UseShellExecute = false;
myproc.Start();
myproc.WaitForExit();
Is there any way to copy a build definition? I work in a mainline source control methodology which utilizes many different branches that live for very short periods (ie. a few days to a week). I'd really like to copy a build template and just change the solution to build. Is there any way to do this?
You can download the new TFS 2010 power tools. It has the option to clone a build definition.
See http://msmvps.com/blogs/molausson/archive/2010/10/21/clone-a-build-definition.aspx for an example
Note: Be aware that the Clone only works when you did NOT pop out the Build window.
You can write an add-in to do it. Here's the code to copy an existing build definition:
static IBuildDefinition CloneBuildDefinition(IBuildDefinition buildDefinition)
{
var buildDefinitionClone = buildDefinition.BuildServer.CreateBuildDefinition(
buildDefinition.TeamProject);
buildDefinitionClone.BuildController = buildDefinition.BuildController;
buildDefinitionClone.ContinuousIntegrationType = buildDefinition.ContinuousIntegrationType;
buildDefinitionClone.ContinuousIntegrationQuietPeriod = buildDefinition.ContinuousIntegrationQuietPeriod;
buildDefinitionClone.DefaultDropLocation = buildDefinition.DefaultDropLocation;
buildDefinitionClone.Description = buildDefinition.Description;
buildDefinitionClone.Enabled = buildDefinition.Enabled;
buildDefinitionClone.Name = String.Format("Copy of {0}", buildDefinition.Name);
buildDefinitionClone.Process = buildDefinition.Process;
buildDefinitionClone.ProcessParameters = buildDefinition.ProcessParameters;
foreach (var schedule in buildDefinition.Schedules)
{
var newSchedule = buildDefinitionClone.AddSchedule();
newSchedule.DaysToBuild = schedule.DaysToBuild;
newSchedule.StartTime = schedule.StartTime;
newSchedule.TimeZone = schedule.TimeZone;
}
foreach (var mapping in buildDefinition.Workspace.Mappings)
{
buildDefinitionClone.Workspace.AddMapping(
mapping.ServerItem, mapping.LocalItem, mapping.MappingType, mapping.Depth);
}
buildDefinitionClone.RetentionPolicyList.Clear();
foreach (var policy in buildDefinition.RetentionPolicyList)
{
buildDefinitionClone.AddRetentionPolicy(
policy.BuildReason, policy.BuildStatus, policy.NumberToKeep, policy.DeleteOptions);
}
return buildDefinitionClone;
}
The following tool (VS Addin) will satisfy your requirement>
Community TFS Build Manager
http://visualstudiogallery.msdn.microsoft.com/16bafc63-0f20-4cc3-8b67-4e25d150102c
I just had a need to copy build definitions, and found Jim's answer above to be helpful. However, being new to the TFS API, I needed help connecting to the server and getting the existing build definition through code. These two links helped fill in the gaps:
http://msdn.microsoft.com/en-us/library/bb286958.aspx
http://geekswithblogs.net/jakob/archive/2010/04/26/creating-a-build-definition-using-the-tfs-2010-api.aspx
You can right click the build definition and select 'clone build definition' to copy the definition file. You can then edit it from there.
Here is the soltion if you want to move the Build definition from one Team Project to other Team project.
public void MoveBuild(string fromTeamProject, string toTeamProject, string buildName, string newBuildName)
{
var _server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new
Uri("http://Mytfs:8080/defaultcollection"));
IBuildServer _buildServer = _server.GetService<IBuildServer>();
var buildDetails = _buildServer.QueryBuildDefinitions(fromTeamProject);
foreach (var fromBuild in buildDetails)
{
if (fromBuild.Name != buildName) continue;
var newBuildDefinition = _buildServer.CreateBuildDefinition(toTeamProject);
newBuildDefinition.Name = !string.IsNullOrEmpty(newBuildName) ? newBuildName : fromBuild.Name;
newBuildDefinition.BuildController = fromBuild.BuildController;
// This finds the template to use
foreach (var mapping in fromBuild.Workspace.Mappings)
{
newBuildDefinition.Workspace.AddMapping(
mapping.ServerItem, mapping.LocalItem, mapping.MappingType, mapping.Depth);
}
newBuildDefinition.DefaultDropLocation = fromBuild.DefaultDropLocation;
newBuildDefinition.Description = fromBuild.Description;
// buildDefinition.Workspace.AddMapping(build.Workspace.);
newBuildDefinition.Process = _buildServer.QueryProcessTemplates(fromBuild)[2];
newBuildDefinition.ProcessParameters = fromBuild.ProcessParameters;
newBuildDefinition.Enabled = false;
newBuildDefinition.Save();
}//end of for each loop
}
From your message it is not clear which template is your build definition using (default, upgrade or lab management). If I understand correctly you would like to easily set up a build definition which builds the same solution but from a different branch.
One thing that you could try instead of copying the definition is to edit it. When the branch dies, rename the build definition (might help with reporting), change the workspace mapping of the build and you should be done.
Thanks, Ladislau