Trying to set up Orleans Cluster membership with Consul - consul

I'm trying to use an existing Consul cluster as the membership provider for a test Orleans application.
I get this error when connecting my client app to the Silo
Could not find any gateway in Orleans.Runtime.Host.ConsulBasedMembershipTable. Orleans client cannot initialize.
Digging into the ConsulUtils class, the entries being retrieved have no ProxyPort defined - and are discarded - hence the empty result set.
I initialize the silo like this:
var clusterConfiguration = new ClusterConfiguration();
clusterConfiguration.Globals.DataConnectionString = "http://localhost:8500";
clusterConfiguration.Globals.DeploymentId = "OrleansPlayground";
clusterConfiguration.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.Custom;
clusterConfiguration.Globals.MembershipTableAssembly = "OrleansConsulUtils";
clusterConfiguration.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.Disabled;
var silohost = new SiloHost("Fred", clusterConfiguration);
silohost.InitializeOrleansSilo();
startup = Task.Factory.StartNew(() =>
{
return silohost.StartOrleansSilo();
});
return true;
And I set my client app up like this:
var config = new ClientConfiguration();
config.CustomGatewayProviderAssemblyName = "OrleansConsulUtils";
config.DataConnectionString = "http://localhost:8500";
config.DeploymentId = "OrleansPlayground";
config.GatewayProvider = ClientConfiguration.GatewayProviderType.Custom;
GrainClient.Initialize(config);
Looking at the code in ConsulUtils I can see that the ProxyPort isn't set (i.e. is 0) when the entry is saved. So I'm assuming I have a problem when initializing the silo - but I can't figure out what it is!

Without digging deep in, does sound like a bug. Please repost on GitHub and we will try to help you.

Related

LLBLGen Pro 5.0 caching with EntityCollectionBase.GetMulti()

I'm using LLBLGen 5.0 and EntityCollectionBase.GetMulti(filter, relation) to retrieve objects in oracle database.
ObjectCollection objects = new ObjectCollection ();
RelationCollection relationsToUse = new RelationCollection();
relationsToUse.Add(ObjectEntity.Relations.Object2EntityUsingObject2Id);
IPredicateExpression filter = new PredicateExpression(ObjectFields.Code == sectionCode);
objects.GetMulti(filter, relationsToUse);
I would like to add caching system to avoid to do request in database many times.
I saw on LLBLGen documentation that it is possible to use cache on LLBLGen with this code:
var customers = new EntityCollection<CustomerEntity>();
using(var adapter = new DataAccessAdapter())
{
var parameters = new QueryParameters()
{
CollectionToFetch = customers,
FilterToUse = CustomerFields.Country=="USA",
CacheResultset = true,
CacheDuration = new TimeSpan(0, 0, 10) // cache for 10 seconds
};
adapter.FetchEntityCollection(parameters);
}
But I'm not able to found class DataAccessAdapter..
Do you have any idea, suggestion to resolve my issue ?
Thanks in advance,
If you created a llblgen project which uses SelfServicing there is no DataAccessAdapter, so project must be created with the Adapter option.
if this is so then it should be in xxxx.DatabaseSpecific
where xxxx is youre project name.

How to programmatically trigger cleanup?

I'm having a very busy build server. On good day we create almost 200gb of artifacts. Cleanup policy can be run once a day which is not enough for my case. I've searched the teamcity documentation and found zero API endpoints to support trigger cleanup manually.
Is it possible to trigger cleanup manually from script/program? How to achieve this?
In worst case I could fiddler up and trace what happens when i manually force cleanup, but its messy road and i don't want to go on it.
here's also C# version
void Main()
{
var cookieContainer = new CookieContainer();
var baseAddress = new Uri("http://teamcity");
var contentDictionary = new Dictionary<string,string>();
contentDictionary["cleanupPageAction"]= "startCleanup";
using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer,
Credentials = new NetworkCredential("user","password","domain")})
using (var client = new HttpClient(handler) { BaseAddress = baseAddress })
{
var content = new FormUrlEncodedContent(contentDictionary);
var result = client.PostAsync("/admin/cleanupPolicies.html", content).Result;
result.EnsureSuccessStatusCode();
}
}
There is no endpoint in the API for this. If you do decide you are happy enough to use the same HTTP POST the dashboard uses for a manual cleanup here it is, simple enough in my opinion:
curl -d "cleanupPageAction=startCleanup" \
http://user:password#builds.company.com/admin/cleanupPolicies.html

TApplicationException: Required field 'client_protocol' is unset

I am developing a thrift client,
I have build a thrift hive server(apache-hive-0.14.0) on my machine and am also have access to Cloudera Dist Hive 4.6.0
When i connect thrift client to CDH client give following error:
TApplicationException: Required field 'client_protocol' is unset!
Struct:TOpenSessionReq(client_protocol:null, username:
I am passing the right protocol to the server but it seems some thing is over riding it....
Moreover if I point to localhost(where i have my hive server running) every thing seems to working fine....
Please let me know what is wrong here....
Code:
var socket = new TSocket("XXX.XXX.XXX.XXX", 10000);
TStreamTransport sTransport = (TStreamTransport)socket;
var transport = new TBufferedTransport(socket);
underlyingTransport = transport;
var proto = new TBinaryProtocol(transport);
var client = new TCLIService.Client(proto);
transport.Open();
TOpenSessionReq req = new TOpenSessionReq(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6);
req.Username = "hive";
req.Password = "hive";
TOpenSessionResp oSResponse = client.OpenSession(req);
TSessionHandle sessionHandle = oSResponse.SessionHandle;
TExecuteStatementReq execReq = new TExecuteStatementReq(sessionHandle, "select * from emp");
TExecuteStatementResp exeRes= client.ExecuteStatement(execReq);
TOperationHandle operationHandle = exeRes.OperationHandle;
TFetchResultsReq fechReq = new TFetchResultsReq(operationHandle,TFetchOrientation.FETCH_FIRST, 1);
TFetchResultsResp fechRes = client.FetchResults(fechReq);
TRowSet results = fechRes.Results;
List<TRow> resultRows = results.Rows;
foreach (var row in resultRows)
{
var val = row.ColVals[0];
System.Console.WriteLine(val.StringVal);
}
TCloseOperationReq closeOprReq = new TCloseOperationReq(operationHandle);
client.CloseOperation(closeOprReq);
TCloseSessionReq creq = new TCloseSessionReq(sessionHandle);
client.CloseSession(creq);
I believe it is the problem of the hive-jdbc version. This solution may solve your problem: Required field 'client_protocol' is unset

CIM in an MVC3 app - how to instantiate ServiceSoap?

I'm integrating CIM into an MVC3 app. I've added a service reference using the development url and coded the following:
public long x()
{
var u = this.User.Identity as IClaimsIdentity;
var id = u.Claims.First(x => x.ClaimType == ClaimTypes.NameIdentifier);
AuthorizeNet.CustomerProfileType cust = new AuthorizeNet.CustomerProfileType();
cust.merchantCustomerId = id.Value;
AuthorizeNet.MerchantAuthenticationType merch = new AuthorizeNet.MerchantAuthenticationType();
merch.name = "8aFRk4663XMd";
merch.transactionKey = "4MS675e62fQEdUXN";
AuthorizeNet.ServiceSoap svc = new AuthorizeNet.ServiceSoap();
AuthorizeNet.CreateCustomerProfileResponseType response = svc.CreateCustomerProfile(
merch, cust, AuthorizeNet.ValidationModeEnum.none
);
return response.customerProfileId;
}
but, of course, it doesn't work because one cannot instantiate an interface like that (.ServiceSoap is an interface). The sample code makes a reference to a .Service - but that doesn't exist AFAICT.
so how is this supposed to work?
TIA - e!
p.s. I did find an old posting with precisely my problem, but alas, no solution
well... at least for now the answer seems to be: don't generate a Service Reference but a Web Reference (you can do it by clicking on the Advanced button of the Service Reference dialogue).
so eeky.

Dynamic site, access session in global

Hello i am currently developing a kind of wiki system for my school, this system uses sub domains to find what course the wiki belongs to. example math1.wiki.com will be the course Math 1.
Now all these wikis use the same database and are given a wiki id, to find what data to load.
Here is the code i use to find the wiki id.
Global.asax
protected void Session_Start()
{
var database = new DataContext();
IWikiRepository rep = new WikiRepository(database);
IWikiService service = new WikiService(rep);
var domain = HttpContext.Current.Request.Url.Authority;
var port = "";
if (domain.Contains(':'))
{
var tmp = domain.Split(':');
domain = tmp[0];
port = tmp[1];
}
var split = domain.Split('.');
var subdomain = split[0];
// if (subdomain == "localhost")
// subdomain = "wiki1";
var wiki = service.GetSite(subdomain);
if (wiki == null)
{
Response.StatusCode = 404;
return;
}
Session["CurrentWiki"] = wiki;
}
This is all fine, but i want to make the mvc system send a 404 request if no wiki was found for the subdomain. But this can not only be done in session_start() as it only runs once per session i have therefor tryed using Application_BeginRequest, but sadly do i not have access to the sessions in the method.
Do any one know how i can implement this?
why can't you just make a custom function that you call at the start of the main page to determine if the wiki exists and if not, redirect/error page/whatever. If it's a custom function, you can just recall it when necessary.

Resources