I am automatically scaling my cosmosDb using azure.DocumentClient. I want to skip if there is existing scaling in progress and wait for 1 minute and try again.
i have suggestion here "https://learn.microsoft.com/en-us/azure/cosmos-db/set-throughput" that I can use DocumentClient.ReadOfferAsync and see the status of the scaling.
I dont understand what property of the return type I should look for in the return type?
The V3 SDK client provides a way to know the status as part of the ThroughputResponse's property IsReplacePending.
This is obtained when ReadThroughputAsync is called on the Container:
Container container = database.GetContainer(containerId);
var throughputResponse = await simpleContainer.ReadThroughputAsync();
This property is checking for a particular Header in the response. If you are using the V2 SDK you can probably check the headers in the ResourceResponse and look for the same headers to know if the upgrade is still pending.
public bool? IsReplacePending
{
get
{
if (this.Headers.GetHeaderValue<string>(WFConstants.BackendHeaders.OfferReplacePending) != null)
{
return Boolean.Parse(this.Headers.GetHeaderValue<string>(WFConstants.BackendHeaders.MinimumRUsForOffer));
}
return null;
}
}
Related
I tried to bookmarking for flash SCORM 1.2 packages. I'm properly capturing the last visited data(cmi.loation, suspend data), but when I'm trying to reset the data for next launch, SCO is not relocating, it is starting from beginning.
And I set the hard coded values in LMSInitilization() function in javascript.
I used bellow code for setting the location variable to SCO.
// cmi data model storing object
var cmiobj = new Object();
function LMSInitialize(dummyString) {
// already initialized or already finished
if ((flagInitialized) || (flagFinished)) { return "false"; }
// set initialization flag
flagInitialized = true;
this.cmiobj["cmi.core.lesson_location"]="6";
this.cmiobj['cmi.core.lesson_status']='incomplete';
this.cmiobj['cmi.core.session_time']='00:00:50';
this.cmiobj['cmi.suspend_data']='FA1Enon ... ";
// return success value
return "true";
}
Hope you help.
You need to set cmi.core.exit to "suspend" too - otherwise it will not supply any of the old data for you to continue with next time.
I am using this code to invalidate CloudFront Files using ASP.NET AWS SDK.
public bool InvalidateFiles(string[] arrayofpaths)
{
try
{
var client = AWSClientFactory.CreateAmazonCloudFrontClient(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY);
CreateInvalidationResponse r = client.CreateInvalidation(new CreateInvalidationRequest
{
DistributionId = ConfigurationManager.AppSettings["DistributionId"],
InvalidationBatch = new InvalidationBatch
{
Paths = new Paths
{
Quantity = arrayofpaths.Length,
Items = arrayofpaths.ToList()
},
CallerReference = DateTime.Now.Ticks.ToString()
}
});
}
catch
{
return false;
}
return true;
}
I supplied a path like "/images/1.jpg" but it seems that the invalidation doesn't take place. I've waited half and hour and used hard refresh and cleared the cache and the image is the same. I've changed the image to look different so I can notice the difference if invalidation has occurred.
In the console I see that the invalidation took place, because I have the ID and in the status I see 'completed', but again, nothing changed in the image.
My question is how can I check that the invalidation takes place and make it work, it seems that I am missing something.
Also, is there an option to create is asynchronous, so I won't need to answer from Amazon.
Thanks.
We are rying to use WF with multiple tracking participants which essentially listen to different queries - one for activity states, one for custom tracknig records which are a subclass of CustomTrackingRecord.
The problem is that we can use both TrackingParticipants indivisually, but not together - we never get our subclass from CustomTrackingRecord but A CustomTrackingRecord.
If I put bopth queries into one TrackingParticipant and then handle everythign in one, both work perfectly (which indicates teh error is not where we throw them).
The code in question for the combined one is:
public WorkflowServiceTrackingParticipant ()
{
this.TrackingProfile = new TrackingProfile()
{
ActivityDefinitionId = "*",
ImplementationVisibility = ImplementationVisibility.All,
Name = "WorkflowServiceTrackingProfile",
Queries = {
new CustomTrackingQuery() { Name = "*", ActivityName = "*" },
new ActivityStateQuery() {
States = {
ActivityStates.Canceled,
ActivityStates.Closed,
ActivityStates.Executing,
ActivityStates.Faulted
}
},
}
};
}
When using two TrackingParticipants we have two TrackingProfile (with different names) that each have one of the queries.
in the track method, when using both separate, the lines:
protected override void Track(TrackingRecord record, TimeSpan timeout)
{
Console.WriteLine("*** ActivityTracking: " + record.GetType());
if (record is ActivityBasedTrackingRecord)
{
System.Diagnostics.Debugger.Break();
}
never result in the debugger hitting, when using only the one to track our CustomTrackingRecord subclass (ActivityBasedTrackingRecord) then it works.
Anyone else knows about this? For now we have combined both TrackingParticipants into one, but this has the bad side effect that we can not dynamically expand the logging possibilities, which we would love to. Is this a known issue with WWF somewhere?
Version used: 4.0 Sp1 Feature Update 1.
I guess I encounterad the exact same problem.
This problem occurs due to the restrictions of the extension mechanism. There can be only one instance per extension type per workflow instance (according to Microsoft's documentation). Interesting enough though, one can add multiple instances of the same type to one workflow's extensions which - in case of TrackingParticipant derivates - causes weird behavior, because only one of their tracking profiles is used for all participants of the respective type, but all their overrides of the Track method are getting invoked.
There is a (imho) ugly workaround to this: derive a new participant class from TrackingParticipant for each task (task1, task2, logging ...)
Regards,
Jacob
I think that this problem isn't caused by extension mechanism, since DerivedParticipant 1 and DerivedParticipant 2 are not the same type(WF internals just use polymorphism on the base class).
I was running on the same issue, my Derived1 was tracking records that weren't described in its profile.
Derived1.TrackingProfile.Name was "Foo" and Derived2.TrackingProfile.Name was null
I changed the name from null to "Bar" and it worked as expected.
Here is a WF internal reference code, describing how is the Profile selected
// System.Activities.Tracking.RuntimeTrackingProfile.RuntimeTrackingProfileCache
public RuntimeTrackingProfile GetRuntimeTrackingProfile(TrackingProfile profile, Activity rootElement)
{
RuntimeTrackingProfile runtimeTrackingProfile = null;
HybridCollection<RuntimeTrackingProfile> hybridCollection = null;
lock (this.cache)
{
if (!this.cache.TryGetValue(rootElement, out hybridCollection))
{
runtimeTrackingProfile = new RuntimeTrackingProfile(profile, rootElement);
hybridCollection = new HybridCollection<RuntimeTrackingProfile>();
hybridCollection.Add(runtimeTrackingProfile);
this.cache.Add(rootElement, hybridCollection);
}
else
{
ReadOnlyCollection<RuntimeTrackingProfile> readOnlyCollection = hybridCollection.AsReadOnly();
foreach (RuntimeTrackingProfile current in readOnlyCollection)
{
if (string.CompareOrdinal(profile.Name, current.associatedProfile.Name) == 0 && string.CompareOrdinal(profile.ActivityDefinitionId, current.associatedProfile.ActivityDefinitionId) == 0)
{
runtimeTrackingProfile = current;
break;
}
}
if (runtimeTrackingProfile == null)
{
runtimeTrackingProfile = new RuntimeTrackingProfile(profile, rootElement);
hybridCollection.Add(runtimeTrackingProfile);
}
}
}
return runtimeTrackingProfile;
}
I'm currently trying to implement an automated bug reporter for a Flex application, and would like to return error messages to a server along with the function/line number that caused the error. Essentially, I'm trying to get the getStackTrace() information without going into debug mode, because most users of the app aren't likely to have the debug version of flash player.
My current method is using the UncaughtErrorEvent handler to catch errors that occur within the app, but the error message only returns the type of error that has occurred, and not the location (which means it's useless). I have tried implementing getStackTrace() myself using a function name-grabber such as
private function getFunctionName (callee:Function, parent:Object):String {
for each ( var m:XML in describeType(parent)..method) {
if ( this[m.#name] == callee) return m.#name;
}
return "private function!";
}
but that will only work because of arguments.callee, and so won't go through multiple levels of function calls (it would never get above my error event listener).
So! Anyone have any ideas on how to get informative error messages through the global
error event handler?
EDIT: There seems to be some misunderstanding. I'm explicitly avoiding getStackTrace() because it returns 'null' when not in debug mode. Any solution that uses this function is what I'm specifically trying to avoid.
Just noticed the part about "I don't want to use debug." Well, that's not an option, as the non-debug version of Flash does not have any concept of a stack trace at all. Sucks, don't it?
Not relevant but still cool.
The rest is just for with the debug player.
This is part of my personal debug class (strangely enough, it is added to every single project I work on). It returns a String which represents the index in the stack passed -- class and method name. Once you have those, line number is trivial.
/**
* Returns the function name of whatever called this function (and whatever called that)...
*/
public static function getCaller( index:int = 0 ):String
{
try
{
throw new Error('pass');
}
catch (e:Error)
{
var arr:Array = String(e.getStackTrace()).split("\t");
var value:String = arr[3 + index];
// This pattern matches a standard function.
var re:RegExp = /^at (.*?)\/(.*?)\(\)/ ;
var owner:Array = re.exec(value);
try
{
var cref:Array = owner[1].split('::');
return cref[ 1 ] + "." + owner[2];
}
catch( e:Error )
{
try
{
re = /^at (.*?)\(\)/; // constructor.
owner = re.exec(value);
var tmp:Array = owner[1].split('::');
var cName:String = tmp.join('.');
return cName;
}
catch( error:Error )
{
}
}
}
return "No caller could be found.";
}
As a side note: this is not set up properly to handle an event model -- sometimes events present themselves as either not having callers or as some very weird alternate syntax.
You don't have to throw an error to get the stack trace.
var myError:Error = new Error();
var theStack:String = myError.getStackTrace();
good reference on the Error class
[EDIT]
Nope after reading my own reference getStackTrace() is only available in debug versions of the flash player.
So it looks like you are stuck with what you are doing now.
I'm trying to develop an application where simultaneous users can interact and i need to have a persistent remote shared object with the list of users currently in session.
When a new user enter in the session he get the server's object with the list. That list was supose to have all the others users in session but is undefined.
I'm doing this first:
users_so = SharedObject.getRemote("users_so", nc.uri, true);
users_so.connect( nc );
users_so.addEventListener( SyncEvent.SYNC, usersSyncHandler );
then i set property to shared object
remoteUsers = new ArrayCollection();
remoteUsers.addItem(displayName);
users_so.setProperty("usersID", remoteUsers);
and finaly i put users in the list.
Thanks!
I would say, that you need to use sharedObject.setDirty("usersID");
SharedObject can't know, that you changed content of ArrayCollection, because the reference to it didn't change. You can use setDirty() to force synch.
Note: The SharedObject.setProperty()
method implements the setDirty()
method. In most cases, such as when
the value of a property is a primitive
type like String or Number, you would
use setProperty() instead of setDirty.
However, when the value of a property
is an object that contains its own
properties, use setDirty() to indicate
when a value within the object has
changed. In general, it is a good idea
to call setProperty() rather than
setDirty(), because setProperty()
updates a property value only when
that value has changed, whereas
setDirty() forces synchronization on
all subscribed clients.
I am using simple dynamic object for this. Client has read-only SharedObject and server decides when to add/remove client from this SharedObject.
m_so is SharedObject (remote), m_userList is Object (local)
if(m_so.data.userList != null) {
for (var key:String in m_so.data.userList) {
if(m_userList[key] == null) {
_addUser(m_so.data.userList[key]);
}
}
for(var clientId:String in m_userList) {
if(m_so.data.userList[clientId] == null) {
_removeUser(clientId);
}
}
}
application.onAppStart = function () {
userList = {};
so = SharedObject.get("roster", false);
so.setProperty("userList", userList);
}
application.onConnect = function (client /*Client*/, userId /*string*/) {
application.acceptConnection(client);
client.userId = userId;
userList[userId] = userId;
so.setProperty("userList", userList);
}
application.onDisconnect = function (client /*Client*/) {
var userId = client.userId;
delete userList[userId];
so.setProperty("userList", userList);
}
I found one solution that works better for me:
It consists in calling remote funcions on server and then broadcast to all clients. The clientes then apply the necessery changes making the solution a lot more stable.